Meaningless Drivel is fun!*
The moose likes Struts and the fly likes Skip validation of a field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Skip validation of a field" Watch "Skip validation of a field" New topic
Author

Skip validation of a field

Srihari Injeti
Ranch Hand

Joined: Jan 05, 2001
Posts: 31
Hi,
I have a requirement where I need to skip validating a field if a check box is checked. How can I use validwhen to achieve this.

Thanks

Sri


Srihari Injeti<BR>SCJP2 MCP CIW
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
See the section entitled "Designing Complex Validations with ValidWhen" in this link.

The entry would probably look something like this:


[ September 07, 2006: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
Srihari Injeti
Ranch Hand

Joined: Jan 05, 2001
Posts: 31
Thanks for your reply. I was doing the same. It works for me as long as the second field is empty.

If the second field is not empty, then it passes the validwhen, and starts validating against the subsequent validators mentioned.

One solution is to blank out the second field when the first checkbox is checked, as we dont intend to validate the second field.

But the requirement is not to blank out the field. For instance, if the user changes his mind, we would like to keep whatever was entered.

I was hoping I can do this without writing a custom validator.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
While the validWhen validator is handy, it's not solution for every possible validation scenario. It sounds like in order to meet all your requirements, you may have to create a custom validation rule.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Skip validation of a field
 
Similar Threads
Question about the required validator
NX: UrlyBird data file format question
B&S: Problem -read field length in bytes
struts 1.? validation
Requirements for taking this exam