Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JSP Form Validation

Status
Not open for further replies.

aarushi2001

Technical User
Nov 16, 2005
109
US
Hi,

I have created a form, which takes and displays user information. I want to add form validation to my form. So far I have been able to validate email, text fields but I dont know how to validate a drop-down (list) field.

I have been able to prompt the user for error if no value is selected but even if user selects a value, it still asks user to select.

Thanks
 
Are you talking about client-side or server-side validation?

Cheers,
Dian
 
I want to validate my form using JSP and beans. I am not able to validate drop-down box (been able to validate check box, textfield and stuff).
 
Perhaps you should say in what ways you are failing to validate :

Does the required value come through ?
What do you determine as "valid" ?
What data are you getting ?
If getting no data, what are you expecting.

its hard to diagnose a problem when all you say is "It doesn't work" ...

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
I did mention what exactly is the problem in my first post of this thread.

In detail:
a user has to select a state. If a user does not select a state, then he should be prompted for an error.

My problem:
even if a user selects a state, he is prompted to select a state.

Data expectation:
If a user selects a state, when he submits or clicks on submit, a page is being dispayed which displays the values entered by the user. In state section, state name should be displayed.
I am not getting any value, cos, till the time user doesnt select the state, he cannot proceed onto next section (basically submit info)

Thanks
 
I still think this is a job for client-side validation, ie, prior to submitting. Javascript is your language.

Cheers,
Dian
 
So, as I asked before, what values are you getting ? What values are you expecting.

I would like to see something like this :

Here is my form variable :

Code:
<select name="myVar">
  <option value="one">one</option>
  <option value="two">two</option>
</select>

In my Java/JSP (or whatever) I do :

Code:
String myVar = request.getParameter("myVar");

Now what I get is "blahbla", but what I really need is "blaBLA".

If you don't get specific - then how can we help you ?
My advise without any info like above would be "it seems broken - I would suggest fixing it" !

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
So ... are you planning on posting more info ?

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
would have.. but solved it..
u shud have said u wanted to see code n explanantion isnt enuff..
no need to be sarcastic

 
How was I being saracstic ?

For future reference ... its a good idea to post code snippets aswell as an explanation.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Sure, you did explain ok, but no one understood you.

Glad you got it to work, because with your explanations and attitude I doubt anyone could offer any help.

Cheers,
Dian
 
Dian, sorry if my explanation was bad and for my attitude but ppl can also ask ques in a better way.

No offense..
 
No problem, I'm not offended at all, just trying to say that if people don't understand your questions, will be very difficult that can provide any answers.

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top