Yes, it works great. 

A couple of things to check -

1.) In the JSP page that is your form, make sure you have -

<html:form action="/myAction" onsubmit="return validateMyExampleForm(this);">

the onsubmit piece is what causes the validation.

2.) At the bottom of the JSP form, set the form name so the validator know what is 
being validated -
<validator:javascript formName="MyExampleForm"/>

Other than that, you should be set.

Ryan


>>> [EMAIL PROTECTED] 07/10/01 01:33PM >>>
I have a small and simple web app that I have working with vanilla
struts. I am trying to incorporate the struts validator mechanism by
converting just one form. To do so, I have done the following:

        Placed the Struts_Validator-20010702.jar into the web app's lib dir.

        Place the jakarta-regexp-1.2.jar into the web app's lib dir.

        Place the struts-validator.tld into the web app's WEB-INF dir
(along with the struts tag lib files).

        Copy the example validation.xml file into the web app's WEB-INF
dir. Removed all but one form from the default (no locale) formset.
Edited each field so that it depends on "require" only. Removed all the
localized formsets.

        Cut & paste from the validator servlet definition from the
example web.xml into mine. Changed the taglib reference for the
validator taglib (no tld durectory).

        Changed the jsp to use the validator:errorsExist tag in place of
the struts errors tag. Added the validator tag lib to the page.

        Changed the form class so that it extends ValidatorForm rather
than struts ActionForm. Commented out my previously coded validate()
method in the form class.

        In the form's action class, remove the check for errors in the
perform() method.

        Added validate="true" to the form's action in the struts-config.xml
file.

When I submit the page with empty fields, no errors are reported and the
form's action just marches merrily along forwarding to the next jsp
which fails because parameters are empty. I have looked and tried again
and again with no luck. Before I give up, I thought I'd ask for help
here. Any ideas as to what I am missing?

Thanks In Advance,

David
Seattle

Reply via email to