Validation Using JSP

Posted on 2006-04-28
Last Modified: 2008-03-17
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.

Question by:vgirijanaidu
    LVL 19

    Accepted Solution

    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.

    LVL 19

    Expert Comment

    by:Jim Cakalic
    Here's a link to another page with javascript source for many sample validations:
    LVL 19

    Expert Comment

    by:Jim Cakalic
    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:

    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!
    LVL 23

    Assisted Solution


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
    Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
    Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
    The viewer will learn how to implement Singleton Design Pattern in Java.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now