Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 418
  • Last Modified:

Validation Using JSP

Currently I have a textbox in JSP. I would like to include a feature wherein, if the user does not input the text accoring to a particular format, then a popup to show up clearing the text box and prompting the user to re-enter. Any snippets of code to acheive this task would be much appreciated else pointers as to how I could go about doing tihis would be great.

Thanks
Sasha
0
vgirijanaidu
Asked:
vgirijanaidu
  • 3
2 Solutions
 
Jim CakalicSenior Developer/ArchitectCommented:
The general approach is, on some event like keyup, blur, or submit, you check the field using JavaScript. Here's a link to a js form validation library that might help you solve the problem. You'll probably want to use a regex rule.
    http://yav.sourceforge.net/en/validationrules.html

Regards,
Jim
0
 
Jim CakalicSenior Developer/ArchitectCommented:
Here's a link to another page with javascript source for many sample validations:
    http://www.shiningstar.net/articles/articles/javascript/javascriptvalidations.asp?ID=ROLLA
0
 
Jim CakalicSenior Developer/ArchitectCommented:
And a third option. This one got a good review by Raible but I can't get to the download site because my corporate filter blocks me:
    http://www.phil-taylor.com/fvalidate/

Since I didn't say it previously, I ought to mention that you shouldn't strictly rely on JavaScript for validation. Whatever validations you are doing, and more, ought to be done on the server as well so that if someone is running with JavaScript disabled you don't allow dirty data through. Having said that, performing some checks on the client side is usually more conducive to the user experience than forcing everything to be done server side only.

Good luck!
Jim
0
 
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now