IntelliJ Java IDE
The moose likes HTML, CSS and JavaScript and the fly likes Field Validation Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Field Validation" Watch "Field Validation" New topic
Author

Field Validation

Deepa Balasubramanayam
Ranch Hand

Joined: Mar 29, 2001
Posts: 39
Hi,
Please give me suggestion.
My form has two fields (User Id and Password).
UserId should be unique. I should allow users to complete the form only if they enter a unique UserID, if not as he enters userid and tabs to Password field, I should check for the exsistance of USerId in the database and alert him to enter a different ID.
Thanks,
Deepa
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50674

Well if you have to check the database, you can't do it completely on the client side. You either need to wait until the user submits the form to check the database as part of the post handling, or (and I DO NOT recommend this) post the form, or a subset of it, every time the user tabs out of the field to check if its value is unique.
Another apporach (which I'd also argue against) is to create a JavaScript array as the page is being constructed (perhaps via JSP) populated with all the existing usernames. A few seconds of thought will reveal why this is not a recommended approach.
The conventional appraoch is to simply perform server-side checks upon form submission.
hth,
bear


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
 
subject: Field Validation
 
Threads others viewed
Focus
BackingBean problem
Restricting to fieldwise validation in StrutsValidation
Pass username and password via browser in Formbased Authentication
how to detect a user if he tries to enter a site without entering his password??
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture