I have a struts application that has a form to edit user details. I am using struts validator to validate the user input.
I have a checkbox that, when clicked, makes ‘Password’ and ‘Confirm Password’ input boxes appear.
If the checkbox box is UNchecked, I do not want the app to validate the invisible input boxes. If I check the checkbox, I then want the validator to kick it.
I have put an c:if around the to only display if the checkbox is checked.
My problem is that the Password/Confirm password validation kicks in, but is invisible.
My question is, is there a way to only validate an input box based on a checkbox value?
Not sure, but i believe you can use validWhen” validation, this validation is for such use-cases for more details refer to the official doc
validator