• 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

Validation three dependent fields using validwhen

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have three dependent fields, with the following condition. I am trying to do it using validwhen, but not able to satisfy all the conditions listed here... Any help is really appreciated.

Condition::::
If (1st contact ==null & 2nd contact ==null & 3rd contact==null)then please select atleast one.
Else if(1st=null && 2nd !=null && 3rd !=null) then 2nd != 3rd
Else if(2st=null && 1st !=null && 3rd !=null) then1st != 3rd
Else if(3rd =null && 1st !=null && 2nd !=null) then 1st != 2nd
Else if (1st !=null &&2nd!=null &&3rd!=null)then
(1st != 2nd && 2nd != 3rd && 3rd != 1st)
[ June 09, 2006: Message edited by: Ranjani Giri ]
 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You will have other two options:
1. You can override the validate() method of your form. The super.validate() method call kicks in first and validates the fields as per the configurations in the validation.xml. Then you can fetch the values of those particular fields and validate them within validate method. Following is the code snippet:


2. You can write a CustomValidator. Declare this custom validator for the third field. You can fetch the values of the all the associated fields within the custom validator and add throw error messages.


Hope this helps.
 
Ran Giri
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I cannot use action forms validate method, as I would lose the consistancy of developement. I was thinking to use Validwhen- The expression just bloats and gets confusing.. Any sudgestion on this really appreciated!!!

Thanks
 
Ran Giri
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Very much. I really appreciate your help. I have the custom validation working.

Thanks
 
Time is mother nature's way of keeping everything from happening at once. And this is a 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