• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

struts date vaidator problem

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic