I have a problem with the form onsubmit function in IE 11. When the submit button was triggered, the "doSomething()"-function will be called. Inside the "doSomething()" function I call another function that does some input-validation stuff. This function always returns false but sets a flag to true if all validation errors are gone. If the flag was set to true, the "doSomething()"-function returns true and the form will be submitted and the action is called. This pattern works in Firefox, Chrome and Safari but doesn't in IE11. In IE it calls the action before the "doSomeValidation()"-Function is ready. :-/ Can anybody help me out here? Thanks a lot!!!
<form action="headToNextPage.php" onsubmit="return doSomething()">
js
flag = false, // a global flag inside the js-script
function doSomeValidation(){
// validate the inputs and set "flag" to true if all errors are gone
}
function doSomething(){
doSomeValidation(); // do the validation stuff
if(flag==true) {
// do some other stuff
return true
}
return false;
}
Replace comma after false to semi colon and add some alert inside the dosomething method its works in IE11 surely
flag = false;