Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Very Urgent : Fututre Date validation using struts validation

 
Vidya Mohandas
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am unable to validate a date field, to not have a future date (the date shud not accept even tomorrows date i.e., it shud not be greater than today's date).
I am using struts validator. Can I do the above mentioned validation using struts validator or I need to have a separate java class for doing the validation (fyi...i shud not use the form bean for any sort of validation)?

Please help me.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to use the validation framework for this, you're going to have to create your own validation rule. Here is a link that shows an example of how to do this:

http://www.onjava.com/pub/a/onjava/2002/12/11/jakartastruts.html?page=1

If you don't want to go to the trouble of creating a custom validation rule, an easier alternative would be to override the validate() method in your ActionForm and have it do the validation instead of the validation framework.
 
Srilakshmi Vara
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I think the best way is to override validate method in ActionForm because you can customize it according to your functionality.

Regards,
Srilakshmi
 
Marco Vanoli
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is possible to use validator framework and at the same time override validate() method for that thing not supported from the framework?
 
Cendy Nguvy
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Yes, it's possible.
Code this following in your ActionForm :


[ July 23, 2005: Message edited by: Cendy Nguvy ]
 
Ganesh Venkat
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do as Merrill Higginson suggested, in that way you will all the validation rules under the Validator framework,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic