Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2 Validation - skip validation for certain fields

 
Anand Krishnanandam
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to validate couple of fields based on the checkBox value.
(checkbox doesn't need validation though)
ex:

if(checkBox.value=false){
validate
name
address
city
graduate school
}else if (checkBox.value=true)
{
skip validation for graduate school
}




any example code or link would be very helpful
Thanks,
Anand
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For a simple case like this where there's only one validation that depends on the checkbox value it'd be easy enough to use the expression validator, which accepts arbitrary expressions.

Anything substantially more complicated than that and I usually end up pushing the validation into Java by using a validate() method.
 
Anand Krishnanandam
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
something like ?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic