Author
Problem with struts <s:select list> validation?
Shrikant Deshpande
Greenhorn
Joined: May 17, 2010
Posts: 15
Problem with <s:select list> validation?
In my jsp page I have list of mentors coming from session.
<s:select list="#allmentors" name="mentorName" headerKey="1" headerValue="-- Select Mentor --"
key="createlabel.selectmentor"/>
Below is the code for my actionclass-validation.xml file.
<field name="mentorName">
<field-validator type="requiredstring">
<message>Please select the mentor</message>
</field-validator>
</field>
In my JSP page,select list shows list of mentors.
If I do not select any mentor name, it shows validation message "Please select the mentor".
But when I select any mentor name from list, it shows the same message "Please select the mentor."
How to do validation for <s:select list>.. ?
If user do not select any mentor from list,then it must display the validation message.
But if user selects any mentor name from list, it should not display validation message.
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
posted May 24, 2010 16:26:23
0
But you've given it a value. And if you're using numeric values, "requiredstring" doesn't seem like a great validation choice, although I guess it'll work?
subject: Problem with struts <s:select list> validation?