How to validate date in struts for different locale.
2 posts in topic
Flat View  Flat View

Posted By:   sats_krish
Posted On:   Thursday, April 22, 2004 10:56 AM

I have a scenario where in i have to validate the form field for the date depending on the locale(US,FR,CA) etc. Whenever the user login to application, we will know his locale and we need to show the date format and then validate the date format for that locale. Is there any easy way of doing this in struts/java. Currently, the validation.xml field property can have only one mask associated with the field..but we need to change the mask depending on the locale.

Please use html tags to format code blocks.

Re: How to validate date in struts for specific format

Posted By:   Shyam_Gupta  
Posted On:   Monday, June 28, 2004 08:58 PM

I am using validator.xml for doing my date validation.
I want date in yyyy/MM/dd format for the same I have used following code in validator.xml


Even if I enter date in proper format I am getting Errors. Could any one help me thanks in advance.

Re: How to validate date in struts for different locale.

Posted By:   Tim_Frith  
Posted On:   Tuesday, April 27, 2004 04:59 PM

You could write your own date validation function(s) in validator-rules.xml.

The form is passed to the validator function (javascript) so you could put the locale in a hidden form field and access it within the function.

This is probably easier to validate (i18n-wise) server-side with one of the DateFormat classes rather than client-side with javascript.

About | Sitemap | Contact