I already solved it, in my form I added another field (maxDay1 and maxDay2)
that will return OK and NG, i used this field in my validation.xml using
validwhen, when the field
is equal to OK, then it is valid, if it is NG, it is invalid..

This is my code, it also checks number of days in february when it is leap
year or not.

//  validate number of days  for month (ViewStartDate)
        public String getMaxDay1(){
                Calendar cal = new GregorianCalendar();
                cal.set(Calendar.MONTH, Integer.parseInt(cal1_Month)-1);
                cal.set(Calendar.YEAR, Integer.parseInt(cal1_Year));
                maxDay1 = "OK";  //初期値
                int maxDayInMonth = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                if (Integer.parseInt(cal1_Day) > maxDayInMonth)
                        maxDay1 = "NG";
                return maxDay1;
        }

        public void setMaxDay1(String maxDay1){
                this.maxDay1 = maxDay1;
        }

// validate number of days  for month (ViewEndDate)
        public String getMaxDay2(){
                Calendar cal = new GregorianCalendar();
                cal.set(Calendar.MONTH, Integer.parseInt(cal2_Month)-1);
                cal.set(Calendar.YEAR, Integer.parseInt(cal2_Year));
                maxDay2 = "OK";   //初期値
                int maxDayInMonth = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                if (Integer.parseInt(cal2_Day) > maxDayInMonth)
                        maxDay2 = "NG";
                return maxDay2;
        }

        public void setMaxDay2(String maxDay2){
                this.maxDay2 = maxDay2;
        }       

-- 
View this message in context: 
http://www.nabble.com/Date-validation-%28month-and-day%29-tf4376264.html#a12514004
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to