Hi,  I am a new user to Struts, using 1.1. I am trying to use the javascript 
validation and not having much luck.  I am trying to model after an example found in 
the Chuck Cavaness's book, but I am not sure if I have all the working pieces 
connected correctly:

1) my form (contactForm) extends ValidatorForm.
2) struts-config.xm entry for validator 

 <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
    <set-property property="pathnames" 
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation-rules.xml" />
 </plug-in>

3) validation.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE form-validation PUBLIC
          "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 
1.0//EN"
          "http://jakarta.apache.org/commons/dtds/validator_1_0.dtd";>
<form-validation>
    <global>
        <constant>
            <constant-name>zip</constant-name>
            <constant-value>^\d{5}</constant-value>
        </constant>
    </global>
    
    <formset>
        <form name="contactForm">
            <field property="firstName" depends="required">
                <arg0 key="First Name" resource="false"/>
            </field>
            <field property="lastName" depends="required">
                <arg0 key="Last Name" resource="false"/>
            </field>
        </form>
    </formset>
</form-validation>

4) validation-rules.xml pulled from struts downloaded distribution
5)  form tag from page -   <html:form action="<%=formName%>" method="post" 
focus="firstName" onsubmit="return validateContactForm(this);">
6) added  errors.required={0} is required. to my resources.

Problem: the javascript validation functions are included but validateContactForm() 
function is not generated.   When I manually add that in to call something like 
validateRequired, I don't get the error messages.  From what I read in the book, the 
validateXXXX for the form should have been automatically generated.

What do I have wrong?

Reply via email to