• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validation three dependent fields using validwhen

 
Ran Giri
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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 ]
 
Durgaprasad Guduguntla
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Thanks Very much. I really appreciate your help. I have the custom validation working.

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic