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" /> </field> I have intentionally left the datePattern blank because I want the default SimpleDateFormat.SHORT Pattern from the session Locale to be used. >From http://struts.apache.org/1.3.10/faqs/validator.html with regard to the >builtin "date" validation "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. -- Sincerely, David Webb, President BrightMove, Inc. (http://www.brightmove.com) 320 High Tide Dr, Suite 101B Saint Augustine Beach, FL 32080 (904) 861-2396 (866) 895-6299 (Fax) --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org