As noted, the default setup of the validation plug in is to validate a FORM which isn’t possible with ASP. To get around this, I decided I was going to wrap all my forms in a FIELDSET with the class “validation Group”.
Using this class as my selection, I’m able to have multiple groups of controls wrapped in a FIELDSET validated separately.
These validator controls will fire even when we navigate between the controls on the page.
For j Query 1.6 the attr() function will not work for Checking and Unchecking Checkbox therefore use prop() in place of attr() in such situations.
Sometimes we want to add a feature in our web page where all checkboxes inside an checkboxlist control gets checked & unchecked from a main checkbox. Here we use a main checkbox control for doing this task then place a click event for this checkbox.
But, clearing the textbox and hitting tab will again enable the error.
So, the validation function is called when we leave the field every time, i.e. Sometimes, it will be better if the validation occurs only when we submit the form and not on blur.
That’s it, with those three little little steps (Custom Validate Method, Disable Default/Auto Bind, Manual bind button to custom event), you now have a working validate by FIELDSET (or any other grouping control) solution. NET will render a Check Box or a Check Box List with an auto generated unique name attribute.
This becomes a problem when you want to validate the group, since you can’t set a common name attribute for all the elements.
Sometimes, when we build an input processing forms we might come across situations where we need to validate controls based on some conditions.
For example, we can make a textbox to be required field only when a checkbox is checked or a dropdownlist value, etc.
Note that before the main logic is executed, the Page_Client Validate method is used in order to validate the page on the client.