?
Solved

need US state validation

Posted on 2005-03-24
4
Medium Priority
?
197 Views
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
0
Comment
Question by:VKopacz
[X]
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
4 Comments
 
LVL 2

Accepted Solution

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





//action.jsp-----------

<%
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))
            found=true;
}
if (!found)
      response.sendRedirect ("form.jsp?err=1");
else
      response.sendRedirect ("thankyou.jsp");
%>






//thankyou.jsp-----------
Thank you !!





0
 
LVL 2

Expert Comment

by:arnon81
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'/>
0

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