Jun 1st, 2010, 01:38 AM
Date field validation in spring mvc
I'm facing a validation problem in my form.
I have 3 fields in my form[Eg: 1)File ref Id 2)From date 3)To date].first field of type String and another 2 fields of type java.util.Date.As per our business validation rules either user has to enter either first field or the remaining two date (date range eg: from date and to date)fields.I have registered CustomDate Editor in my SimpleFormController.
I have one Validator class also.If the user enters first field the validation for Date fields should be skipped.If the user enters only one date field(say From date), an error message should be displayed "To Date is required".
If the user dont enter any of the fields, an error message should be displayed "Either either File ref Id or date range i.e from date and to date".
The problem here is if the user enters File ref id and click submit button, as the date fields is of type java.util.Date in the commandBean and as I have CustomDate editor,the Errors object in the validate method still contains errors.and my onSubmit() method is not getting invoked.
Any help would be appriciated.
Thanks in Adavance.