[jQuery] Validate groups of input fields, checkbox highlight and reset
Hi,
I have 3 problems I need to solve:
1. Validate groups of input fields. I see in the example of tabs, you
can do as follows:
// validate the other two selects when one changes to update the
whole group
var birthdaySelects = $("#birthdateGroup select").click(function() {
birthdaySelects.not(this).valid();
});
However, mine is not using select, but it is using input text field.
So I modify the code into:
// validate the other two inputs when one changes to update the whole
group
var birthdayInputs = $("#birthdateGroup input").keyup(function() {
birthdayInputs.not(this).valid();
});
However, it is not working with the input fields. Please help to make
it works.
2. Checkbox highlight. I am using a class highlight for all the
errors. I use required checkbox, so at least 1 checkbox must be
checked. If I check the first item, then uncheck, the error message
appear and the error class highlight also successfully displayed.
However, if I check the second or the third (etc) item, then uncheck,
only the error msg appear, the error class doesn't highlight. Here is
my code:
highlight: function( element, errorClass, validClass ) {
$(element).parents('li').addClass(errorClass).removeClass
(validClass);
},
unhighlight: function( element, errorClass, validClass ) {
$(element).parents('li').removeClass(errorClass).addClass
(validClass);
},
3. Reset function not working. Here is my code:
var v = $('.myForm').validate({ .... bla... bla ... bla});
$('#resetButton').click(function() {
v.resetForm();
});
I figure this is caused by I am using a highlight class (see item 2
above).
Please help me to find the solution for this. I am still learning
Jquery, but I do find it very useful.
THanks in advance for all the help.