Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

form validation

 
Naresh Chaurasia
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi folks,
i am trying to build a form where there are lot of components. my requirement is to validate each component in the form, when user loses focus.

I found some validation code on http://www.javascript-coder.com/html-form/javascript-form-validation.phtml site, but it works only when the form is submitted.

Can someone tell me if i can find code on net, which would help me do validations for all the components while losing focus.

thnx in advance.

N Chaurasia
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to add validation to every element than.

onblur="ValidateSomeField()"

Eric
 
Naresh Chaurasia
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eric,
i have defined textbox1, textbox2. onblur of textbox1 i call alphabetsValidation and onblur of textbox2 i call numbersValidation. In alphabetsValidation i check if textbox1 lenght is 0, then i set the foucs to textbox1.

In numbersValidation i check if textbox2 lenght is 0, then i set the foucs to textbox2.

Now if i move my cursor from textbox1 to textbox1, then it goes in infinit loop...

what can i do to resolve the problem

thnx in advance
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic