Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

datePatternStrict : checking yyyy

 
Venkat Babu
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot.
 
Nick Williamson
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic