This week's book giveaway is in the Java in General forum.
We're giving away four copies of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 and have ishori Sharan & Adam L Davis on-line!
See this thread for details.
Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic