struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John <>
Subject Server side RegExp validation fails yet client side works (using DynaValidatorForm)
Date Tue, 17 Dec 2002 18:46:23 GMT
I'm currently using the Struts 1.1b version. I have a
problem where I define a simple form with a single
field; I need to have the field validated using
"required", "minlength" and "mask" validation
operators. I'm using DynaValidatorForm's to avoid the
overhead of implementing a concrete ActionForm class. 

When the client-side validation tags are inserted into
the JSP file, all three (client-side) validation
operators work perfectly. 

I commented out the <html:javascript> code and
onsubmit handler in the JSP file to test the server
side validation. (Is there an easier way?)

When I did this, the server side only validated with
the "required" and "minlength" seemed
to totally disregard the "mask" validation operation. 

I searched all of the FAQ's and google search result
sets and couldn't find anything quite like this...
Has anybody else experienced this? Am I missing

(I realize that the regular expression I'm using
evaluates to digits only and that I could try using an
existing validation like "int". I found, however, that
the client side (javascript) implementation of
parseInt() is not what I'm looking for since "12fga"
will "pass" the parseInt() call)

Thank you for looking at my problem!

Here are the details; I'm using the un-modified
version of validator-rules.xml that shipped with the
struts1.1b jar file.

Here are the other files:

----> FILE: <-----------------
----> offerDetails.jsp <-----
--> (Note: client side validation has been removed)<--

<%@ taglib uri="/WEB-INF/struts-html.tld"
prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld"
prefix="bean" %>

	<H3>Offer Details Page</H3>
	<html:form action="/GetDates" method="post">
	  Type in offer number:
	  <input type="text" name="offerId">
	  <input type="submit" name="submit">

----> FILE: <-----------------
----> struts-config.xml <-----

    <form-bean name="offerDetailsForm"  
    <form-property name="offerId"

    <action path="/GetDates" validate="true" 

				name="offerDetailsForm" input="/offerDetails.jsp">
			<forward name="success" path="/roomDates.jsp"/>
			<forward name="skipdate" path="/roomPrefs.jsp"/>
			<forward name="failure" path="/offerDetails.jsp"/>
parameter="com.mycompany.ApplicationResources" />

		<set-property property="pathnames"


----> FILE: <-----------------
----> validation.xml <-----

<?xml version="1.0"?>
  <form name="offerDetailsForm">
   <field property="offerId"
   <msg name="mask" key="numbers.only"/>
   <arg0 key="offerDetails.offerId.displayname"/>
   <arg1 name="minlength" key="${var:minlength}"

----> FILE: <-----------------
----> <-----
----> (abbreviated) <--------

errors.header=<h3><font color="red">Error
offerDetails.offerId.displayname=Special Identifier
errors.required={0} is required.
errors.minlength={0} cannot be less than {1}
errors.invalid={0} is invalid.
numbers.only=Data must be comprised of numbers only.


Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message