File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts Validator Client side question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Validator Client side question" Watch "Struts Validator Client side question" New topic

Struts Validator Client side question

Raghu Marpalli

Joined: Jul 30, 2006
Posts: 6

I am using Struts Validator for client side javascript validation. I have single ActionForm that collects information across multiple pages. Some fields are required on one page while some on the next. I would like non-visible fields to not be validated by the form. How can I acheive the same?

The validator complains that I need to provide values for the fields that are not visible but still part of the form.

Thanks in advance for any assistance.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
At the moment, I can't think of a way to turn validation off for some fields, but not for others.

I suppose you could put some sort of value in the fields to indicate "This field has not been filled out yet" that will allow it to pass validation. This seems kind of awkward to me, though, and not a very good solution.

You may end up having to create a separate ActionForm for each page and have each form bean copy its properties to a common bean that is kept in the session.
[ July 30, 2006: Message edited by: Merrill Higginson ]

Consultant, Sima Solutions
It is sorta covered in the JavaRanch Style Guide.
subject: Struts Validator Client side question
Similar Threads
Using struts validator to check onchange events.
Validwhen validator client side javascript
Bypass client-side struts validation
struts validator
Struts 1.2 - Client and Server-side validations