Announcement Announcement Module
Collapse
No announcement yet.
Validations on Custom Property Editors Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Validations on Custom Property Editors

    In our application we have a requirement that for all the date fields accross the application two validations need to performed on binding. The validations are as follows:
    1. Invalid Date if the date format does not follow the pattern mm/dd/yyyy
    2. The date should be always greater than 01/01/1900

    How do I tie two validation errors for the field on onBind? Based on the validation only one validation error has to be shown at any time. We are already using a CustomDateEditor that is taking care of the first validation.

    Can anyone plaease let me know if this is possible. If so how?

    Thanks in advance,
    --Vijay

  • #2
    In your controller override the initBinder method and register your date format. This will take care of the date format.

    Then override the onBindAndValidate method, include some logic to check that the date is after 1900 and add it to the BindException if it isnt ( aErrors.rejectValue() )

    Comment


    • #3
      onBindAndValidate will work but I do not want to add validation code for each date field in different pages across the application. This validation of date greater than 1900 should be applied globally across the application. Any kind of help is appriciated.

      Comment

      Working...
      X