Struts2 JQuery DatePicker: set maxDate to today

1.7k Views Asked by At

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" />
1

There are 1 best solutions below

1
On BEST ANSWER

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.