commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Miller" <>
Subject [Validator] New user trying to use Javascript validation
Date Sun, 07 Dec 2003 04:33:34 GMT
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"

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"
        <form name="contactForm">
            <field property="firstName" depends="required">
                <arg0 key="First Name" resource="false"/>
            <field property="lastName" depends="required">
                <arg0 key="Last Name" resource="false"/>

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?
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message