Onblur prevents onsubmit on form submission
I have validation functions that are called on the onblur
appropriate input field. at the same time I call the same validation functions with one function validateall()
and get validateall()
called on onsubmit
. now the problem is that some error happened and I corrected it and submitted the form at this time when it is called onblur
which prevents the event from being triggered onsubmit
. this is the problem i only faced in Firefox.
JavaScript:
function validateFormOnSubmit(theForm)
{
vUsername(theForm.userName,document.getElementById('UError'));//this will return true or false depends on error occurrence.
}
HTML:
<form name="form" onsubmit="return validateFormOnSubmit(this);">
<input type="text" id="userName" onblur="vUsername(this,UError);">
// UError is the div id where I will print error messages.
source to share
Use delay () function or setTimeOut () function for onBlur.
this link will help you too. jQuery onblur check
source to share