How does one validate two dates with one another on the same form?  As seen 
in the snippets below, I've added the validators in the onSubmit() of the form 
which actually works, though not on the first time the form is submitted only on
subsequent submittals.  Could someone throw me a bone on how to get this
to work when the form is submitted for the first time?  Thanks in advanced!

<snippet_1>
 // Date 1 field
date1Field = new DateTextField("date1Field", new Model(),
    new PatternDateConverter(dateFormat, false));
date1Field.setRequired(true);
DateTextField.forDatePattern("date1", dateFormat);
date1Field.add(new DatePicker());
date1Field.clearInput();

// Date 2 field
date2Field = new DateTextField("date2Field", new Model(),
    new PatternDateConverter(dateFormat, false));
date2Field.setRequired(true);
DateTextField.forDatePattern("date2", dateFormat);
date2Field.add(new DatePicker());
date2Field.clearInput();
</snippet_1>

<snippet_2>
add(
form = new Form("form") {
    @Override
    protected void onSubmit() {
    SimpleDateFormat format = new SimpleDateFormat(dateFormat);
    try {                    
        
date1Field.add(DateValidator.maximum(format.parse(date2Field.getInput())));
        
date2Field.add(DateValidator.minimum(format.parse(date1Field.getInput())));     
               
    } catch (ParseException ex) {
        throw new RuntimeException(ex);
    }
    }
};
)
</snippet_2>



      

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

Reply via email to