How would I check my date input so that it will validate the maximum days per month. For example: Jan, Mar, May, Aug, Oct, Dec (31 days) April, June,Sept, Nov (30 days)...
Hi If you intend to use javascript,this can be easily done by putting if else condition.Please note that you will require year field also to validate for February.
thank you for your reply, but if I used javascript, I will not be using alert message for the error message instead I should use the html:error.. Will it be possible?
I'd suggest doing server-side validation in the validate() method of your ActionForm. I'd use the parse method of the SimpleDateFormat class. This class will simply throw a ParseException if the date is invalid. If it does, catch it and format an ActionError instance. Since the Java base classes handle all the details of date validation, why re-invent the wheel?
Oh, and one other thing: Make sure you call setLenient(false) on the SimpleDateFormat instance. [ September 04, 2007: Message edited by: Merrill Higginson ]
Hi Merill's suggestion is good,only problem being the call to the server.Incase you don't mind that,you can use it. Also,not sure if we can use html:error incase of Java script. Apple Man
thank you for your replies.. Ive already solved this..
In my form I added another field (maxDay1 and maxDay2) that will return OK and NG, i used this field in my validation.xml using validwhen, when the field is equal to OK, then it is valid, if it is NG, it is invalid..
This is my code, it also checks number of days in february when it is leap year or not.