Turn off struts validation per input box based on checkbox value - struts

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

Related

Check some field before opening confirmation box in ODOO

I want to check that if some fields in the form view has been checked or not. If they have been checked then show a confirmation message and if not then a error message saying that those fields must be checked. For this functionality I have created a button which calls a specific function in the model. The button has also attribute confirm which enables the confirmation pop up box. But all the time it first opens the confirmation message and then the checking for the fields. I want to have the other way around how to achieve this. Please help.

Reset function with checkboxes in Struts 1.3

I've got a problem. I heard something about the Struts reset function but I never see any example and I don't know how to write it.
I heard it can help when I have such a case:
I have few checkboxes checked, then in my form I click next and go to next page, then I click back and go again to the page with checkboxes, uncheck few of them and check the others and click next again. Then, validation errors appear as if I those checkboxes which I unchecked were still checked.
Do you know how to use it in this case?
In the action form you can override the reset() method and initialize the checkbox property value to its default state. This only needed if your action form is session scoped. Thus it could contain values of the unchecked checkboxes before you submit or reset button pressed.
You can see the example Struts <html:checkbox> checkbox example.

Ignore invisible field validation during form data submit

I have a form panel having fields like textfield and radio buttons.There are some conditions to hide textfield as per the radio button value.
have added custom validation to textfield.Suppose i have enter a invalid value to a text filed, then i clicked the radio button. as per my condition that invalid text field is now invisible.
Except that invisible field all other fields are valid. Now i want to submit the form data.
Is it possible to ignore the invisible field while submitting the form panel data.?
Thanks
Set the field not only to hidden as also to disabled, that will solve this. Or as mentioned in the comment if you just use a custom validation return true.

How to validate the optional field?

As per the requirements, "XYZ" field is mandatory field, but this field is optional in the form which I am testing.
"XYZ" is a text field. So when I automate the form, whether that field is empty or filled it passes. In reality, this test should fail.
I am using TestNG and selenium.
Thanks!!!
Leave the text field empty, click on Submit to submit the form.
Check for any validations "Please enter text here." or "1 missed field".
if the the validation alert is not seen, the test script will fail and that is how you will catch it.
Think of selenium as a way to replicate a real user click through on a website. So when manually clicking through, you clicked to submit the form and went to the next page when you actually expected a validation alert.

Silverlight 4 : Restrict checking of checkbox to box only

I wanted to know if its possible to disallow checking/unchecking of checkbox on clicking checkbox label and only allow checking/uncecking of the box on the box only.
PS: I want to pull it off without using an additional label for the checkbox i.e I wish to disable check/uncheck of checkbox on the checbox label
checking the template (here), can't see clearly how to do that. Additionally it does not have any NamedPart. For me the easiest way is that you suggested... or create your own checkbox.