| Author |
how to do validation?
|
Liz Brown
Ranch Hand
Joined: Oct 22, 2002
Posts: 112
|
|
I have 2 fields on my jsp: start date and end date. I have to put some validation that the startDate user enters in always less than or equal to the end date. (I have myAction which extends ValidatorForm. I am using validation.xml to put required field check.)
|
 |
Nathaniel Stoddard
Ranch Hand
Joined: May 29, 2003
Posts: 1258
|
|
|
It sounds like you already know how to do validating for your ActionForm. What part exactly are you having problems with? Also, have you read the Struts documentation on build in validators for the ValidatorPlugin?
|
Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
|
 |
Liz Brown
Ranch Hand
Joined: Oct 22, 2002
Posts: 112
|
|
i have same problem. I have startdate, end date. I have validator.xml. (using validation plugin) I have put both as required fields in this file. but how to check if one is greater than another?
|
 |
alan do
Ranch Hand
Joined: Apr 14, 2005
Posts: 354
|
|
|
you need to write your own custom validation. look for samples online. the most common example you'll find is the validate identical (eg. if the user entered the same password for 2 fields). base on that example, you can do your date compare validation.
|
-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
|
 |
Liz Brown
Ranch Hand
Joined: Oct 22, 2002
Posts: 112
|
|
|
Has anybody done this before? Could you please point me to some useful information on what I am looking for.thanks.
|
 |
Anything Possible
Greenhorn
Joined: May 13, 2005
Posts: 1
|
|
|
It looks like someone took the time to document the solution at http://www.junlu.com/msg/159728.html
|
 |
alan do
Ranch Hand
Joined: Apr 14, 2005
Posts: 354
|
|
every struts developer should have a shortcut to http://struts.apache.org/userGuide/index.html for your question, look at the validatTwoFields example in the validator docs: http://struts.apache.org/userGuide/dev_validator.html
|
 |
MInu
Ranch Hand
Joined: Oct 09, 2003
Posts: 517
|
|
Write a small function for testing if the first date is greater than the second one. then add the error to action error object.(valErrors.add("date", new ActionError("errors.date"));
|
God Gave Me Nothing I Wanted<br />He Gave Me Everything I Needed<br /> - Swami Vivekananda
|
 |
Jason Menard
Sheriff
Joined: Nov 09, 2000
Posts: 6450
|
|
Originally posted by vinod: Write a small function for testing if the first date is greater than the second one. then add the error to action error object.(valErrors.add("date", new ActionError("errors.date"));
"vinod", We don't have many rules here, but we do have a naming policy which we try to strictly enforce. Please re-read this document and edit your display name in order to comply.
|
Jason's Blog
|
 |
MInu
Ranch Hand
Joined: Oct 09, 2003
Posts: 517
|
|
|
 |
 |
|
|
subject: how to do validation?
|
|
|