开发者

Validation Problem in Struts 2

开发者 https://www.devze.com 2023-03-02 15:33 出处:网络
I have a date fields in jsp splitted into 3 text boxes , each text box corresponds to DD , MM & YYYY respectively.

I have a date fields in jsp splitted into 3 text boxes , each text box corresponds to DD , MM & YYYY respectively. So I ha开发者_运维技巧ve defined 3 String fields in my action to get those values. Now I have to merge the three fields and for a date object to persist in Database.

Where I am stuck is how to validate in XML. To validate individual text boxes I have used regex to check correct format of data. It displays three error messages in case I do not fill date as I am not able to short circuit regex validations.

Also how to do validation like date should not be greater than current date .

can somebody post a sample code to short circuit regex expression for 3 different fields? Help is appreciated.

Thanks

Rajiv


validate DD to be between 01 and 31. MM to be between 01 and 12, YYYY to be whatever range of years you wish to allow.

Then use new SimpleDateFormatter("dd-MM-YYYY") when you concat your three strings together with "-"'s in between.

0

精彩评论

暂无评论...
验证码 换一张
取 消