4

i have validation functions which is being called on onblur of respective input field. at the same time i am calling same validation functions with one say validateall() function and validateall() is being called on onsubmit. now the problem is if some error has occured and i have corrected it and submit the form at that time onblur is being called which is preventing from calling onsubmit event. this problem i am facing in Firefox only.

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 div id where i'll be printing error msgs.

2 Answers2

1

Use delay() function or setTimeOut() function for onBlur.

this link also helps you.. jQuery validation onblur

Community
  • 1
  • 1
sasi
  • 4,192
  • 4
  • 28
  • 47
0

Add a setTimeout-function to your onBlur-event. To hand over your parameters you have to use a anonymous function:

<input type="text" id="userName" onblur="setTimeout(function(){ vUsername(this,UError) }, 200);">

Now your submit-event should be faster than onBlur :-)

alexP
  • 3,672
  • 7
  • 27
  • 36
  • You could use onFocus instead of onBlur: http://stackoverflow.com/questions/3639908/retrieving-previously-focused-element – alexP Feb 08 '13 at 16:04