wood burning stoves*
The moose likes HTML, CSS and JavaScript and the fly likes form validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "form validation" Watch "form validation" New topic

form validation

Naresh Chaurasia
Ranch Hand

Joined: May 18, 2005
Posts: 356
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

SCJP 1.4, SCWCD1.4, OCA(1Z0-007)
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15376
You need to add validation to every element than.


Naresh Chaurasia
Ranch Hand

Joined: May 18, 2005
Posts: 356
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
It is sorta covered in the JavaRanch Style Guide.
subject: form validation
Similar Threads
How can I open a JSF page as a non modal dialog
Is there any validation plugin in place of Javascript
java script for sending mails from webpage
pop up window hides itself when parent is closed
How call a servlet method