struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David T. Webb" <>
Subject Date Validation using session Locale
Date Mon, 27 Jul 2009 16:23:55 GMT
I am using Struts 1.3.10  and I am trying to achieve client side javascript date validation
using the default datePattern from the user's session Locale.  Objective is to validate any
date format based on Locale without specifying a specific pattern.

My Form field validation rule is this:

<field property="DOB" depends="required,date">
      <arg key="ApplicantForm.DOB.displayName" />

I have intentionally left the datePattern blank because I want the default SimpleDateFormat.SHORT
Pattern from the session Locale to be used.

>From with regard to the builtin "date"

"If no pattern is specified the default short date format is assumed."

The session Locale is set to en_US.

I am getting an error on the javascript length ("datePattern.length") because datePattern
is not set properly in the cliet side js.

As you can see below, from the  javascript generated on the page, it looks for the datePatternStrict
and datePattern settings from the validation.xml file.  But it never defaults to the SHORT
format from the session Locale using SimpleDateFormat as specified in the validator docs.

           var value = field.value;
           var isStrict = true;
           var datePattern = oDate[x][2]("datePatternStrict");
           // try loose pattern
           if (datePattern == null) {
               datePattern = oDate[x][2]("datePattern");
               isStrict = false;
           if ((field.type == 'hidden' ||
                field.type == 'text' ||
                field.type == 'textarea') &&
               (value.length > 0) && (datePattern.length > 0))

What am I doing wrong?  Does anyone have this working properly?

Thank you.

David Webb, President
BrightMove, Inc. (
320 High Tide Dr, Suite 101B
Saint Augustine Beach, FL 32080
(904) 861-2396
(866) 895-6299 (Fax)

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

View raw message