jquerystruts2datepickerstruts2-jquerystruts2-jquery-plugin

Struts2 JQuery DatePicker: set maxDate to today


I want the maxDate to be set to the current date.

I've tried with this answer but I still have problems.

Here is my code:

<sj:datepicker id = "dob"        
             name = "dateOfBirth" 
            label = "Date Of Birth" 
      changeMonth = "true"  
       changeYear = "true"    
        yearRange = "1980" 
          maxDate = "0"      
         readonly = "true" />

Solution

  • Use

    <sj:datepicker 
        ....
        maxDate="%{new java.util.Date()}"
    />
    

    or return new Date() from a getter, and use the code in the other answer you linked.