The javascript should work, yes. I haven't tried this with serverside
validation though. DatePattern works (or is supposed to work)
differently than datePatternStrict, so be aware that if you were
counting on datePattern functionality serverside, it may not work as you
had expected.

-Andy

-----Original Message-----
From: Brice Ruth [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, December 30, 2003 10:44 AM
To: Struts Users Mailing List
Subject: Re: Date validation problem?


Aha, so all I need to do is change "datePattern" to "datePatternStrict" 
in my XML?

Andy Schmidgall wrote:

>datePattern doesn't work -- you must use datePatternStrict unless you 
>modify the javascript validation function.
>
>This line is where the pattern is loaded:
>
>var datePattern = oDate[x][2]("datePatternStrict");
>
>Notice that it's loading datePatternStrict instead of datePattern from 
>the oDate object. The validation function completely ignores the 
>datePattern var you defined in the xml.
>
>You're getting the error because it's trying to load from the 
>datePatternStrict var which isn't defined, so the javascript 
>datePattern var isn't a valid object.
>
>-Andy
>
>-----Original Message-----
>From: Brice Ruth [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, December 30, 2003 9:55 AM
>To: Struts Users Mailing List
>Subject: 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to