You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Brice Ruth <br...@fiskars.com> on 2003/12/30 16:55:19 UTC
Date validation problem?
I'm testing the JavaScript validation for my form and noticed that the
JavaScript generated to validate my date fields throws an error that I
can see in Firebird's JavaScript console. Here's the error:
datePattern has no properties
and here's the line it occurs on:
for (x in oDate) {
var value = form[oDate[x][0]].value;
var datePattern = oDate[x][2]("datePatternStrict");
>> if ((form[oDate[x][0]].type == 'text' || form[oDate[x][0]].type == 'textarea') && value.length > 0 && datePattern.length > 0) {
var MONTH = "MM";
var DAY = "dd";
var YEAR = "yyyy";
I can see that my date fields appear correctly in DateValidations(), here:
function DateValidations () {
this.aa = new Array("theStartDate", "Availability Start Date is not a valid date.", new Function ("varName", "this.datePattern='MM/dd/yy'; return this[varName];"));
this.ab = new Array("theEndDate", "Availability End Date is not a valid date.", new Function ("varName", "this.datePattern='MM/dd/yy'; return this[varName];"));
}
And in my validation.xml file, the following is defined:
<field property="theStartDate" depends="required,date">
<arg0 key="form.orangeThumbApp.theStartDate"/>
<var>
<var-name>datePattern</var-name>
<var-value>${defaultDate}</var-value>
</var>
</field>
<field property="theEndDate" depends="required,date">
<arg0 key="form.orangeThumbApp.theEndDate"/>
<var>
<var-name>datePattern</var-name>
<var-value>${defaultDate}</var-value>
</var>
</field>
Where ${defaultDate} is a global defined as:
<constant>
<constant-name>defaultDate</constant-name>
<constant-value>MM/dd/yy</constant-value>
</constant>
From what I can see in DateValidations(), it looks like the var-value
is being picked up correctly ... so, I'm at a bit of a loss on this. Is
this a know bug in Struts 1.1?
Also, does using DynaValidatorForm with validation.xml and such *only*
do JavaScript validation or is server-side validation performed as well?
It'd be a nice bonus to have server-side validation, to prevent corrupt
or malicious submittals, but that may require a custom ActionForm?!
--
Brice D. Ruth
Sr. IT Analyst
Fiskars Brands, Inc.
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org