• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Field Validation

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic