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

struts date vaidator problem

Mitesh K Patel
Greenhorn

Joined: Nov 24, 2005
Posts: 3
Hi,

I have been using struts inbuilt validation framework for my application.

i m using it to validate date format in 'dd/MM/yyyy'

in my validation.xml file,
<field property="fromDate" depends="date">
<arg key="testReportBean.fromDate"/>
<var>
<var-name>datePattern</var-name>
<var-value>dd/MM/yyyy</var-value>
</var>
</field>

i want date like '1/1/2006' as a valid date. Dont want user to strictly input '01/01/2006'. the above scriptlet strictly want the date entered with leading zeros.

In all the material available on internet, i hv read tht if var-name is 'datePattern' then it should not validate strictly for the date with leading zeros.
But its not working for me.

Can any one pls help me on this issue.

Thanx.
Ergin Er
Ranch Hand

Joined: Sep 06, 2005
Posts: 60
I don't get it. If you define the pattern to be dd/MM/yyyy, then you can't blame the validator to expect leading zeros conform to the pattern. Making the leads optional sounds more like "regex" to me.
The only date validation within validator framework I can find is "isDate" that checks if the date is valid.
Mitesh K Patel
Greenhorn

Joined: Nov 24, 2005
Posts: 3
Hi,

In my application user is also allowed to input date, and i do not want use to enter date in strict format.

And in struts validation framework, there are two variable available ,

if i use datePatternStrict, then only it should check for perfect date format with leading zero.

if i use datePattern, then it should allow date like, 1/11/2006, and should not give error message,

But still 'datePattern' is not working.

Is there any problem with version of struts jar file ?

Thanx,
Mitesh
Ergin Er
Ranch Hand

Joined: Sep 06, 2005
Posts: 60
by the way: the dependency date that you're using and the variable datePattern don't seem to be in sync. Maybe you should try changing depend=date to depend=datePattern
Marwin kovarex
Greenhorn

Joined: Dec 15, 2005
Posts: 1
I have the same problem with validator, validation routines are written in way, that doesn't accept formates like d.M.yyyy(it looks for "dd" "MM" in the javascript cod), and changing datePatterStrict to datePattern, which should make the thing doesn't help too.
Is somewhere some corrected validateDate function, that i could replace?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts date vaidator problem
 
Similar Threads
Date Validator scrolls the date
struts validation
future date validation
Required field usage
Date Formatting Problem with Validator