• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Date validation in struts....

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have two date fields: Start date and End date and i want my start date to be lesser than end date. I want this to be done using validation.xml in struts. Can any body help me out in this!!!???!!!
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its "validwhen" type of validation I suggest you should first go thru this link:
http://struts.apache.org/1.3.10/faqs/validator.html#Designing_Complex_Validations_with_validwhen


And Welcome to JavaRanch
And no need to make it bold and green, its already a lot greeny out side my window, thanks to monsoon.
 
Varsha Goswami
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey thanks a lot for your immediate reply...will check into it...

I use green coz its one of my favourite colors.......


Thanks,
 
Varsha Goswami
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

I tried this code but its not working... could you please check if this is the right way to code.....or there is something else to be done in this case....!!!

<field property="startDate" depends="required,date,validwhen">
<var>
<var-name>datePatternStrict</var-name>
<var-value>MM/dd/yyyy</var-value>
</var>
<arg key="error.blank.startdate"/>
<var>
<var-name>test</var-name>
<var-value>((endDate > startDate) or (*this* == null))</var-value>
</var>
</field>

<field property="endDate" depends="required,date,validwhen">
<var>
<var-name>datePatternStrict</var-name>
<var-value>MM/dd/yyyy</var-value>
</var>
<arg key="error.blank.enddate"/>
<var>
<var-name>test</var-name>
<var-value>((endDate > startDate) or (*this* == null))</var-value>
</var>
</field>
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please use CodeTags

And I may quick in first reply, but I understood this wouldn't solve your problem, because I suspect validwhen doesn't support "date" fields only string and primitive data type, still I correct an error for you



Try this code. Also if you want this validwhen approach, then you have break up the date field in three text boxes, like
[day] [month] [year] and then need to check the larger values in end date.

If it still fails then you have to write one plugbale validator for your own requirements, example:
http://raibledesigns.com/rd/date/20030226
 
Varsha Goswami
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome
 
Just let me do the talking. Ahem ... so ... you see ... we have this tiny ad...
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic