• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
There are 29 Knuts in one Sickle, and 17 Sickles make up a Galleon. 42 tiny ads in a knut:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic