You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Erik Weber <er...@mindspring.com> on 2004/08/27 00:25:21 UTC

Re: date parsing/validation...newbie 23/Jan/2004 and 23/JAN/2004

Hmm, sorry, I don't use client-side form validation. For one, I found 
that the scripts generated by the Validator plugin measured 38K, which 
is ridiculous.

This is my validation.xml config for a date field that I tried for you:

<field property="myDate" depends="date">
    <arg0 key="myMessageKey"/>
    <var>
       <var-name>datePatternStrict</var-name>
       <var-value>dd/MMM/yyyy</var-value>
    </var>
</field>

I tested it with 23/JUL/2004, which passed, and 23/JIL/2004, which 
failed. I didn't test any more thoroughly than that.

Please try without the JavaScript to see if the Struts validation 
behaves as you expect. If it does, blame the JavaScript (which you can 
edit in validator-rules.xml).

Erik




Research labs wrote:

>Erik,
>
>I have just tried datePatternStrict; the client side
>validator now tells me that 23/Jan/2004 and
>23/JAN/2004 are not dates.
>
>Thank you.
>
>
>Ola.
>
>
>
> --- Erik Weber <er...@mindspring.com> wrote: 
>  
>
>>Try "datePatternStrict" as the var-name instead of
>>"datePattern".
>>
>>Erik
>>
>>
>>Research labs wrote:
>>
>>    
>>
>>>Hi, 
>>>
>>>Please help me.  
>>>
>>>I am trying to force users to enter dates in the
>>>format 23/JAN/2003, therefore, I have the setting
>>>below in the validator.xml.  The maxlength bit
>>>      
>>>
>>works,
>>    
>>
>>>but date parsing does not work, for example the
>>>validator does not complain if I enter an invalid
>>>      
>>>
>>date
>>    
>>
>>>such as 23/JJJ/1996. As you are aware, JJJ is not a
>>>valid month.  Can you please tell me what I am
>>>      
>>>
>>doing
>>    
>>
>>>wrong.
>>>	<field property="dob"
>>>                   depends="maxlength,date">
>>>                   <arg0 key="cargoForm.dob"/>
>>>                  <arg1 name="maxlength"
>>>key="${var:maxlength}" resource="false"/>
>>>                   <var>
>>>                     
>>><var-name>datePattern</var-name>
>>>                     
>>><var-value>dd/MMM/yyyy</var-value>
>>>                   </var>
>>>                   <var>
>>>                     
>>>      
>>>
>><var-name>maxlength</var-name>
>>    
>>
>>>                      <var-value>11</var-value>
>>>                   </var>
>>>	</field>
>>>		If you have any example or link to a doc, please
>>>send it. 	
>>>
>>>Thank you.
>>>
>>>Ola.
>>>
>>>
>>>
>>>
>>>--- Research labs <re...@yahoo.co.uk>
>>>      
>>>
>>wrote: 
>>    
>>
>>> 
>>>
>>>      
>>>
>>>>Noted. Thank you very much.
>>>>
>>>>--- Erik Weber <er...@mindspring.com> wrote: 
>>>>   
>>>>
>>>>        
>>>>
>>>>>Looks to me like you probably want dd/MM/yyyy.
>>>>>
>>>>>Erik
>>>>>
>>>>>
>>>>>Erik Weber wrote:
>>>>>
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>>>Please see the API documentation for
>>>>>>       
>>>>>>
>>>>>>            
>>>>>>
>>>>>java.text.SimpleDateFormat's 
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>>>pattern syntax, which you are violating with
>>>>>>       
>>>>>>
>>>>>>            
>>>>>>
>>>>>DD/MON/YYYY. "MON" is not 
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>>>an acceptable token, and DD is day-in-year, not
>>>>>>       
>>>>>>
>>>>>>            
>>>>>>
>>>>>day in month.
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>>>Erik
>>>>>>
>>>>>>
>>>>>>Research labs wrote:
>>>>>>
>>>>>>       
>>>>>>
>>>>>>            
>>>>>>
>>>>>>>Can anyone please tell what I can do in order
>>>>>>>         
>>>>>>>
>>>>>>>              
>>>>>>>
>>>>to
>>>>   
>>>>
>>>>        
>>>>
>>>>>stop
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>>>>users from entering invalid dates. The
>>>>>>>         
>>>>>>>
>>>>>>>              
>>>>>>>
>>>>validator
>>>>   
>>>>
>>>>        
>>>>
>>>>>does
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>>>>not raise an error if a user enters 33 as ad
>>>>>>>         
>>>>>>>
>>>>>>>              
>>>>>>>
>>>>day,
>>>>   
>>>>
>>>>        
>>>>
>>>>>as
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>>>>in this sample date: 33/jan/2000.
>>>>>>>
>>>>>>>I am using Struts validator, which is setup as
>>>>>>>follows:
>>>>>>><field property="dob"
>>>>>>>depends="maxlength,date">
>>>>>>><arg0 key="cargoForm.dob"/>
>>>>>>><arg1 name="maxlength"
>>>>>>>key="${var:maxlength}" resource="false"/>
>>>>>>><var>
>>>>>>><var-name>datePattern</var-name>
>>>>>>><var-value>DD/MON/YYYY</var-value>
>>>>>>></var>
>>>>>>><var>
>>>>>>><var-name>maxlength</var-name>
>>>>>>><var-value>11</var-value>
>>>>>>></var>
>>>>>>></field>
>>>>>>>
>>>>>>>Thanks.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>         
>>>>>>>
>>>>>>>              
>>>>>>>
>>___________________________________________________________ALL-NEW
>>    
>>
>>> 
>>>
>>>      
>>>
>>>>>>>Yahoo! Messenger - all new features - even more
>>>>>>>         
>>>>>>>
>>>>>>>              
>>>>>>>
>>>>>fun! 
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>>>>http://uk.messenger.yahoo.com
>>>>>>>
>>>>>>>
>>>>>>>         
>>>>>>>
>>>>>>>              
>>>>>>>
>>---------------------------------------------------------------------
>>    
>>
>>> 
>>>
>>>      
>>>
>>>>>>>To unsubscribe, e-mail:
>>>>>>>         
>>>>>>>
>>>>>>>              
>>>>>>>
>>>>>user-unsubscribe@struts.apache.org
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>>>>For additional commands, e-mail:
>>>>>>>         
>>>>>>>
>>>>>>>              
>>>>>>>
>>>>>user-help@struts.apache.org
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>>>>         
>>>>>>>
>>>>>>>              
>>>>>>>
>>>>>>       
>>>>>>
>>>>>>            
>>>>>>
>>---------------------------------------------------------------------
>>    
>>
>>> 
>>>
>>>      
>>>
>>>>>>To unsubscribe, e-mail:
>>>>>>       
>>>>>>
>>>>>>            
>>>>>>
>>>>>user-unsubscribe@struts.apache.org
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>>>For additional commands, e-mail:
>>>>>>       
>>>>>>
>>>>>>            
>>>>>>
>>>>>user-help@struts.apache.org
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>>>       
>>>>>>
>>>>>>            
>>>>>>
>>>>>     
>>>>>
>>>>>          
>>>>>
>>---------------------------------------------------------------------
>>    
>>
>>> 
>>>
>>>      
>>>
>>>>>To unsubscribe, e-mail:
>>>>>user-unsubscribe@struts.apache.org
>>>>>For additional commands, e-mail:
>>>>>user-help@struts.apache.org
>>>>>
>>>>>
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>	
>>>>	
>>>>		
>>>>
>>>>   
>>>>
>>>>        
>>>>
>>___________________________________________________________ALL-NEW
>>    
>>
>>> 
>>>
>>>      
>>>
>>>>Yahoo! Messenger - all new features - even more
>>>>        
>>>>
>>fun!
>>    
>>
>>>>http://uk.messenger.yahoo.com
>>>>
>>>>   
>>>>
>>>>        
>>>>
>>>	
>>>	
>>>		
>>>      
>>>
>>___________________________________________________________ALL-NEW
>>Yahoo! Messenger - all new features - even more fun!
>> http://uk.messenger.yahoo.com
>>    
>>
>>---------------------------------------------------------------------
>>    
>>
>>>To unsubscribe, e-mail:
>>>      
>>>
>>user-unsubscribe@struts.apache.org
>>    
>>
>>>For additional commands, e-mail:
>>>      
>>>
>>user-help@struts.apache.org
>>    
>>
>>> 
>>>
>>>      
>>>
>>    
>>
>---------------------------------------------------------------------
>  
>
>>To unsubscribe, e-mail:
>>user-unsubscribe@struts.apache.org
>>For additional commands, e-mail:
>>user-help@struts.apache.org
>>
>> 
>>    
>>
>
>
>	
>	
>		
>___________________________________________________________ALL-NEW Yahoo! Messenger - all new features - even more fun!  http://uk.messenger.yahoo.com
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: date parsing/validation...newbie 23/Jan/2004 and 23/JAN/2004

Posted by "O. Oke" <re...@yahoo.co.uk>.
Thanks for your advice, I will do as you suggested.  I
am confident that this will work. However, I am unable
to test it straight away because I have just come
accross another unrelated problem.

Regards.

Ola.


    --- Erik Weber <er...@mindspring.com> wrote: 
> Hmm, sorry, I don't use client-side form validation.
> For one, I found 
> that the scripts generated by the Validator plugin
> measured 38K, which 
> is ridiculous.
> 
> This is my validation.xml config for a date field
> that I tried for you:
> 
> <field property="myDate" depends="date">
>     <arg0 key="myMessageKey"/>
>     <var>
>        <var-name>datePatternStrict</var-name>
>        <var-value>dd/MMM/yyyy</var-value>
>     </var>
> </field>
> 
> I tested it with 23/JUL/2004, which passed, and
> 23/JIL/2004, which 
> failed. I didn't test any more thoroughly than that.
> 
> Please try without the JavaScript to see if the
> Struts validation 
> behaves as you expect. If it does, blame the
> JavaScript (which you can 
> edit in validator-rules.xml).
> 
> Erik
> 
> 
> 
> 
> Research labs wrote:
> 
> >Erik,
> >
> >I have just tried datePatternStrict; the client
> side
> >validator now tells me that 23/Jan/2004 and
> >23/JAN/2004 are not dates.
> >
> >Thank you.
> >
> >
> >Ola.
> >
> >
> >
> > --- Erik Weber <er...@mindspring.com> wrote: 
> >  
> >
> >>Try "datePatternStrict" as the var-name instead of
> >>"datePattern".
> >>
> >>Erik
> >>
> >>
> >>Research labs wrote:
> >>
> >>    
> >>
> >>>Hi, 
> >>>
> >>>Please help me.  
> >>>
> >>>I am trying to force users to enter dates in the
> >>>format 23/JAN/2003, therefore, I have the setting
> >>>below in the validator.xml.  The maxlength bit
> >>>      
> >>>
> >>works,
> >>    
> >>
> >>>but date parsing does not work, for example the
> >>>validator does not complain if I enter an invalid
> >>>      
> >>>
> >>date
> >>    
> >>
> >>>such as 23/JJJ/1996. As you are aware, JJJ is not
> a
> >>>valid month.  Can you please tell me what I am
> >>>      
> >>>
> >>doing
> >>    
> >>
> >>>wrong.
> >>>	<field property="dob"
> >>>                   depends="maxlength,date">
> >>>                   <arg0 key="cargoForm.dob"/>
> >>>                  <arg1 name="maxlength"
> >>>key="${var:maxlength}" resource="false"/>
> >>>                   <var>
> >>>                     
> >>><var-name>datePattern</var-name>
> >>>                     
> >>><var-value>dd/MMM/yyyy</var-value>
> >>>                   </var>
> >>>                   <var>
> >>>                     
> >>>      
> >>>
> >><var-name>maxlength</var-name>
> >>    
> >>
> >>>                      <var-value>11</var-value>
> >>>                   </var>
> >>>	</field>
> >>>		If you have any example or link to a doc,
> please
> >>>send it. 	
> >>>
> >>>Thank you.
> >>>
> >>>Ola.
> >>>
> >>>
> >>>
> >>>
> >>>--- Research labs <re...@yahoo.co.uk>
> >>>      
> >>>
> >>wrote: 
> >>    
> >>
> >>> 
> >>>
> >>>      
> >>>
> >>>>Noted. Thank you very much.
> >>>>
> >>>>--- Erik Weber <er...@mindspring.com> wrote:
> 
> >>>>   
> >>>>
> >>>>        
> >>>>
> >>>>>Looks to me like you probably want dd/MM/yyyy.
> >>>>>
> >>>>>Erik
> >>>>>
> >>>>>
> >>>>>Erik Weber wrote:
> >>>>>
> >>>>>     
> >>>>>
> >>>>>          
> >>>>>
> >>>>>>Please see the API documentation for
> >>>>>>       
> >>>>>>
> >>>>>>            
> >>>>>>
> >>>>>java.text.SimpleDateFormat's 
> >>>>>     
> >>>>>
> >>>>>          
> >>>>>
> >>>>>>pattern syntax, which you are violating with
> >>>>>>       
> >>>>>>
> >>>>>>            
> >>>>>>
> >>>>>DD/MON/YYYY. "MON" is not 
> >>>>>     
> >>>>>
> >>>>>          
> >>>>>
> >>>>>>an acceptable token, and DD is day-in-year,
> not
> >>>>>>       
> >>>>>>
> >>>>>>            
> >>>>>>
> >>>>>day in month.
> >>>>>     
> >>>>>
> >>>>>          
> >>>>>
> >>>>>>Erik
> >>>>>>
> >>>>>>
> >>>>>>Research labs wrote:
> >>>>>>
> >>>>>>       
> >>>>>>
> >>>>>>            
> >>>>>>
> >>>>>>>Can anyone please tell what I can do in order
> >>>>>>>         
> >>>>>>>
> >>>>>>>              
> >>>>>>>
> >>>>to
> >>>>   
> >>>>
> >>>>        
> >>>>
> >>>>>stop
> >>>>>     
> >>>>>
> >>>>>          
> >>>>>
> >>>>>>>users from entering invalid dates. The
> >>>>>>>         
> >>>>>>>
> >>>>>>>              
> >>>>>>>
> >>>>validator
> >>>>   
> >>>>
> >>>>        
> >>>>
> >>>>>does
> >>>>>     
> >>>>>
> >>>>>          
> >>>>>
> >>>>>>>not raise an error if a user enters 33 as ad
> >>>>>>>         
> >>>>>>>
> >>>>>>>              
> >>>>>>>
> >>>>day,
> >>>>   
> >>>>
> >>>>        
> >>>>
> >>>>>as
> >>>>>     
> >>>>>
> >>>>>          
> >>>>>
> >>>>>>>in this sample date: 33/jan/2000.
> >>>>>>>
> >>>>>>>I am using Struts validator, which is setup
> as
> >>>>>>>follows:
> >>>>>>><field property="dob"
> >>>>>>>depends="maxlength,date">
> >>>>>>><arg0 key="cargoForm.dob"/>
> >>>>>>><arg1 name="maxlength"
> >>>>>>>key="${var:maxlength}" resource="false"/>
> >>>>>>><var>
> >>>>>>><var-name>datePattern</var-name>
> >>>>>>><var-value>DD/MON/YYYY</var-value>
> >>>>>>></var>
> >>>>>>><var>
> >>>>>>><var-name>maxlength</var-name>
> >>>>>>><var-value>11</var-value>
> >>>>>>></var>
> >>>>>>></field>
> >>>>>>>
> >>>>>>>Thanks.
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>         
> >>>>>>>
> >>>>>>>              
> >>>>>>>
>
>>___________________________________________________________ALL-NEW
> >>    
> >>
> >>> 
> >>>
> >>>      
> >>>
> >>>>>>>Yahoo! Messenger - all new features - even
> more
> >>>>>>>         
> >>>>>>>
> >>>>>>>              
> >>>>>>>
> >>>>>fun! 
> >>>>>     
> >>>>>
> >>>>>          
> >>>>>
> >>>>>>>http://uk.messenger.yahoo.com
> >>>>>>>
> >>>>>>>
> >>>>>>>         
> >>>>>>>
> >>>>>>>              
> >>>>>>>
>
>>---------------------------------------------------------------------
> >>    
> >>
> >>> 
> >>>
> >>>      
> >>>
> >>>>>>>To unsubscribe, e-mail:
> >>>>>>>         
> >>>>>>>
> >>>>>>>              
> >>>>>>>
> >>>>>user-unsubscribe@struts.apache.org
> >>>>>     
> >>>>>
> >>>>>          
> >>>>>
> >>>>>>>For additional commands, e-mail:
> >>>>>>>         
> >>>>>>>
> >>>>>>>              
> >>>>>>>
> >>>>>user-help@struts.apache.org
> >>>>>     
> >>>>>
> >>>>>          
> >>>>>
> >>>>>>>         
> >>>>>>>
> >>>>>>>              
> >>>>>>>
> >>>>>>       
> >>>>>>
> >>>>>>            
> >>>>>>
>
>>---------------------------------------------------------------------
> >>    
> >>
> >>> 
> >>>
> >>>      
> >>>
> >>>>>>To unsubscribe, e-mail:
> >>>>>>       
> >>>>>>
> >>>>>>            
> >>>>>>
> >>>>>user-unsubscribe@struts.apache.org
> >>>>>     
> >>>>>
> >>>>>          
> >>>>>
> >>>>>>For additional commands, e-mail:
> >>>>>>       
> >>>>>>
> >>>>>>            
> >>>>>>
> >>>>>user-help@struts.apache.org
> >>>>>     
> >>>>>
> >>>>>          
> >>>>>
> >>>>>>       
> >>>>>>
> >>>>>>            
> >>>>>>
> >>>>>     
> >>>>>
> >>>>>          
> >>>>>
>
>>---------------------------------------------------------------------
> >>    
> >>
> >>> 
> >>>
> >>>      
> >>>
> >>>>>To unsubscribe, e-mail:
> >>>>>user-unsubscribe@struts.apache.org
> >>>>>For additional commands, e-mail:
> >>>>>user-help@struts.apache.org
> >>>>>
> >>>>>
> >>>>>     
> >>>>>
> >>>>>          
> >>>>>
> >>>>	
> >>>>	
> >>>>		
> >>>>
> >>>>   
> >>>>
> >>>>        
> >>>>
>
>>___________________________________________________________ALL-NEW
> >>    
> >>
> >>> 
> >>>
> >>>      
> >>>
> >>>>Yahoo! Messenger - all new features - even more
> >>>>        
> >>>>
> >>fun!
> >>    
> >>
> >>>>http://uk.messenger.yahoo.com
> >>>>
> >>>>   
> >>>>
> >>>>        
> >>>>
> >>>	
> >>>	
> >>>		
> >>>      
> >>>
>
>>___________________________________________________________ALL-NEW
> >>Yahoo! Messenger - all new features - even more
> fun!
> >> http://uk.messenger.yahoo.com
> >>    
> >>
>
>>---------------------------------------------------------------------
> >>    
> >>
> >>>To unsubscribe, e-mail:
> >>>      
> >>>
> >>user-unsubscribe@struts.apache.org
> >>    
> >>
> >>>For additional commands, e-mail:
> >>>      
> >>>
> >>user-help@struts.apache.org
> >>    
> >>
> >>> 
> >>>
> >>>      
> >>>
> >>    
> >>
>
>---------------------------------------------------------------------
> >  
> >
> >>To unsubscribe, e-mail:
> >>user-unsubscribe@struts.apache.org
> >>For additional commands, e-mail:
> >>user-help@struts.apache.org
> >>
> >> 
> >>    
> >>
> >
> >
> >	
> >	
> >		
>
>___________________________________________________________ALL-NEW
> Yahoo! Messenger - all new features - even more fun!
>  http://uk.messenger.yahoo.com
> >
>
>---------------------------------------------------------------------
> >To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> >For additional commands, e-mail:
> user-help@struts.apache.org
> >
> >
> >  
> >
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 
>  


	
	
		
___________________________________________________________ALL-NEW Yahoo! Messenger - all new features - even more fun!  http://uk.messenger.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org