I have a form which contain some radio button and check-boxes. Whenever user selects/deselects a radio button or check-box few other input fields are enabled/disabled.
I want to add validation only for fields which are enabled when user submits the form. Fields which are disabled at the time of submission should not be considered for validation.
I don’t want to add this in client side validation.Is there any better /easy way to implement conditional validation in Spring 3.0 instead of adding multiple if in validator ?
Thanks!
When fields are disabled they are transferred to controller as
null. I wanted to add a validation which will allow eithernulli.e disabled field ornot blankfield i.e. enabled but empty field.So I created a custom annotation
NotBlankOrNullwhich will allownulland non empty strings also it takes care of blank spaces.Here is my Annotation
Validator class
I have also updated more details on my site.