Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Problem with OnBlur


Message #1 by gbrown@c... on Wed, 31 Jul 2002 16:24:58
Hi all

I have a form which uses an onBlur event to run Javascript validation on 
text inputs.

This is air code (not tested)
<input type=text name=text1 value="1" onblur="validate(this)"
<input type=text name=text2 value="2" onblur="validate(this)"

<script>
function validate(o)
alert(o.value)
return 
</script>

The construct I use is something similar but some also then launch popups.
My problem is that this code quite happily alerts "1" press a key then it 
alerts 2 then 1 and so on without letting me input anything. This means I 
have to close the browser task before I can do anything.

My question that by the time onBlur runs focus has already moved to the 
next control in sequence therefore the alert then triggers that ones 
onBlur. In other program languages I have a method that fires before the 
focus is moved. Does Javascript have anything similar? or is it possible 
to turn off events on the form while I run validation then turn them on 
again.

Hope this is sort of clear. Appreciate any help.

Regards



  Return to Index