I have a JSP page where I have put a JS code for confirm() method. I am calling this from the form "onsubmit". The dialog box has 2 buttons "OK' and 'cancel'. On clicking "OK" the form should be submitted which is happening but on click of 'cancel' button I need to redirect the page to some other page. Below is the JS code.
function showDialog() {
if(confirm("Press OK to confirm")) {
console.log("Clicked OK, confirmation.");} else {
console.log("Clicked Cancel, confirmation.");
}
Below is the form tag where I am calling JS function:
<form:form name="login" id="login" action="<%=loginPass%>" method="POST" autocomplete="off" onsubmit= "showDialog()">