Page Re-load/refresh After JavaScript Alert - Dont Want It Do!
My JavaScript function is working but for some reason after the alert is displayed inside my IF statement the page re-loads/refresh and I do not want it to. Why is this and how can
Solution 1:
Here is your complete function with the return false statement added.
Additionally, when you call valSubmit, it should look like this:
... onsubmit="return valSubmit();"...
Note, you need to specify return here also.
Here is the function:
function valSubmit(){
varName = document.form1.txtName.value;
varSurname = document.form1.txtSurname.value;
varEmail = document.form1.txtEmail.value;
varOrg = document.form1.txtOrg.value;
if (varName == "" || varSurname == "" || varEmail == "" || varOrg == "" )
{
alert("Please fill in all mandatory fields");
return false;
}
else
{
document.body.style.cursor = 'wait';
document.form1.btnSubmit.style.cursor = 'wait';
document.form1.action = "http://now.eloqua.com/e/f2.aspx"
document.form1.submit();
return true;
}
}
Solution 2:
you have to add return false;
to stop the default action from taking place from the form submit
Solution 3:
I guess you should add return false;
after your alert
, because the form goes on submitting.
Solution 4:
Just ad return false after alert. Like:
alert("Please fill in all mandatory fields");
return false;
Post a Comment for "Page Re-load/refresh After JavaScript Alert - Dont Want It Do!"