need US state validation

Posted on 2005-03-24
Medium Priority
Last Modified: 2010-04-01

Client does not want STATe dropdown. Please provide a validation using JSP, Struts or Java

Please DON'T point me to a piece of documentation.  I need specifics  since I'm new to the web world

This is my 3rd request for this in Experts exchange --- very frustrating web site
Question by:VKopacz
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Accepted Solution

arnon81 earned 2000 total points
ID: 13626612
if (request.getParameter("err")!=null)
      out.println ("Please correct state name");
<form method='post' action='action.jsp'>
<input type=text name='state'/>
<input type=submit value=submit/>


String[] states = {"IA", "CA", "MO"}; //add more state as you wish....
String inputstate = request.getParameter("state");

boolean found=false;
for (int i=0; i<states.length; i++)
      if (states[i].equals(inputstate))
if (!found)
      response.sendRedirect ("form.jsp?err=1");
      response.sendRedirect ("thankyou.jsp");

Thank you !!


Expert Comment

ID: 13626620
oh and on form.jsp
might be better to use
<input type=text name='state' maxlength='2'/>
instead of
<input type=text name='state'/>

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
This month, Experts Exchange’s free Course of the Month is focused on CompTIA IT Fundamentals.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

764 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