I am working a webproject using struts2 and I used struts2 jquery plugin for datepicker.
Now I need to validate ToDate depending on FromDate.
ToDate shouldnot be greater than FromDate
validation should be like this, datepicker should disable the behind dates accodring to fromdate.Then user not able to select lower than the from date
Please let me know how can I implemt this.
Please post the code will help
Thanks in advance
That’s your choice how you want to impliment the validation.There are 2 ways which as of now seems feasible to me
For the first part your both data-picker must have id and name so once user filled
ToDateandFromDateand before submitting the form you can call a java-script function where you can fetch the values of respective date-picker fields using java-scriptdocument.getEmelemntById()and can run your comparison logic.Other option is to let Struts2 fill the
ToDateandFromDatevalues in your action class and you can usevalidatemethod inside your Action to perform date validation.choice is all yours.You can even play around with validation framework even.
Update
After playing around with J query plugin source code here is the workaround we have
In similar way can work for other way around.Hope this will work for you.