aspose file tools*
The moose likes Struts and the fly likes datePatternStrict : checking yyyy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "datePatternStrict : checking yyyy" Watch "datePatternStrict : checking yyyy" New topic
Author

datePatternStrict : checking yyyy

Venkat Babu
Ranch Hand

Joined: Jan 12, 2007
Posts: 47
Hi,

I am using datePatternStrict for one of the date field.

<field property="corpDate" depends="date">
<arg0 key="error.incdate"/>
<var>
<var-name>datePatternStrict</var-name>
<var-value>MM/dd/yyyy</var-value>
</var>
</field>


But I need to check the year is from 1900 to 2000. The user cannot
enter 0001 or 1899. I am not sure how I can do this. Could someone give me some idea? Thanks.
Sri Anand
Ranch Hand

Joined: Mar 06, 2005
Posts: 392
You will have to write your own custom validation , I guess Struts validation only checks the pattern, If implementing a cutom validation is too much of pain you would end up writing a custom Java script
Venkat Babu
Ranch Hand

Joined: Jan 12, 2007
Posts: 47
Thanks a lot.
Nick Williamson
Ranch Hand

Joined: Jan 06, 2007
Posts: 73
the easiest way to do that is to override the validate method on your form, call super, then check if the date is null or what have you, then get the year and validate it there. That way all your validation is contained in the form. Or you could try min/max with dates (I've never tried that but it might be worth a shot).
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: datePatternStrict : checking yyyy