• 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 validation help needed....

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have a form that has a dropdowm list. If user picks a specific value from that dropdown list, I need to check another field in the form with a value greater than zero. For all other picks from the dropdown, I don't have to worry. Any suggestion will be very helpfull.

And also I am using client side validation, If any body can suggest me how to check two password field is same or not, that will be great.

Thanks in advance..........
[ October 17, 2007: Message edited by: K Amin ]
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For your first question, get the parameter from the form bean and compare the values to your expected value using the .equals method. If true, then check the other field.
For your second question just use the javascript if field1 == field2, then do something
 
K Amin
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks John.
I know how to compare 2 fields in java script. But the thing I dont know how to use this javascript function with struts validation, cause other fields of the same form is validated by struts validation. Any suggestion will be appreciated. thanks again.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may be able to use the validwhen rule for this. For details, see the Struts Validator Guide.
[ October 17, 2007: Message edited by: Merrill Higginson ]
 
K Amin
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Merrill,

Yes the password checks is working fine with validwhen. But I am having problem with displaying message in window alert. Here is my code, 1st 3 requied field displays fine in pop-up window, but when it comes to validwhen, it dosn't. Again if both passwords are same it works fine. If anybody can help me, that will be great.

<form name="changePasswordForm">
<field property="oldpassword" depends="required">
<arg0 key="label.oldpassword"/>
</field>
<field property="newpassword" depends="required">
<arg0 key="label.newpassword"/>
</field>
<field property="newpasswordAgain" depends="required,validwhen">
<arg0 key="label.newpasswordAgain" />
<msg name="validwhen" key="Both new password should be same."/>
<var>
<var-name>test</var-name>
<var-value>((newpassword == newpasswordAgain) or (*this* == newpassword))</var-value>
</var>
</field>
</form>

Thanks again....
 
I suggest huckleberry pie. But the only thing on the gluten free menu is this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic