Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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 ]
 
Get me the mayor's office! I need to tell her about this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic