File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes STRUTS:client-side validation using validation.xml for hidden field results in error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "STRUTS:client-side validation using validation.xml for hidden field results in error" Watch "STRUTS:client-side validation using validation.xml for hidden field results in error" New topic
Author

STRUTS:client-side validation using validation.xml for hidden field results in error

Tanveer Rameez
Ranch Hand

Joined: Dec 11, 2000
Posts: 158
hi,
I am using client-side validation in a JSP in struts environment.
The script to enable client-side validation in the JSP form is :

My validation conditions are:
1. age>18 and age <75
2. term>0 and term <40
3. (age+term) <80
I have one <html:text property="age"> for age and another <html:text property="term"> for term. Now to hold the value of (age+term) i have a <html:hidden property="ageTermSum"> whose value is set to (age+term) before submission by a java script.
Now in the validation.xml i have this code:


I get javascript error when validation for ageTermSum fails (i.e if age+term >80). When I change the hidden field to a textfield it works fine. That is, if i replace <html:<b>hidden</b> property="ageTermSum"> by
<html:<b>text</b> property="ageTermSum"> and if the validation for that property fails, I get a alert message indicating the error. and then the focus goes to the textfield ;. This is usually how client-sdie validation in struts happens..i.e. the focus goes to the field with error.
So what I can guess is that, when the field is hidden type, focus cannot go to that field and so javascript error occurs. Am I right?
If so can I prevent the focus from going to that field only or is that any other approach?
Thanks
Tanveer
[ August 27, 2004: Message edited by: Tanveer Rameez ]

Author of JPhotoBrush Pro (www.jphotobrushpro.com)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: STRUTS:client-side validation using validation.xml for hidden field results in error