[jQuery] Re: jquery validation: manually set the form validity state?

2008-11-07 Thread kedr

Would using resetForm() help me in any way?


On Nov 6, 3:11 pm, kedr [EMAIL PROTECTED] wrote:
 I have a form that is split into 3 different tabs. You can only move
 to the next tab if the part of the form on the current tab is valid. I
 have 3 separate validator code sections each with their own rules and
 messages. I attach an onclick handler to the custom button to return
 ('#myForm').validate().form() and if it returns true to move on to the
 next tab. However, on the next tab I can click the next button and
 it moves on, even though all the fields should have errors. I assume
 that maybe the overall state of the form is valid, so calling .form()
 again returns true. I'm wondering what the best solution is to
 validating a form split into 3 different tabs. I was thinking that
 when a tab opens, you set the form valid state (if it's possible) to
 false everytime. But I wonder if then once you call .form() it returns
 false no matter what since you manually set it? This seems like a
 quick fix and possibly bad idea, anybody have any suggestions?


[jQuery] jquery validation: manually set the form validity state?

2008-11-06 Thread kedr

I have a form that is split into 3 different tabs. You can only move
to the next tab if the part of the form on the current tab is valid. I
have 3 separate validator code sections each with their own rules and
messages. I attach an onclick handler to the custom button to return
('#myForm').validate().form() and if it returns true to move on to the
next tab. However, on the next tab I can click the next button and
it moves on, even though all the fields should have errors. I assume
that maybe the overall state of the form is valid, so calling .form()
again returns true. I'm wondering what the best solution is to
validating a form split into 3 different tabs. I was thinking that
when a tab opens, you set the form valid state (if it's possible) to
false everytime. But I wonder if then once you call .form() it returns
false no matter what since you manually set it? This seems like a
quick fix and possibly bad idea, anybody have any suggestions?


[jQuery] problems with unhighlight of error labels with jquery validation 1.4

2008-11-05 Thread kedr

my js is as follows:

var validator = $('#myForm').validate({
onfocusout: false,
onkeyup: false,

rules: {
prefix: { required: true },
name: { required: true }
},

messages: {
prefix: { required: 'Please select a prefix' },
name: { required: 'Please provide your name' }
},

errorClass: 'formError',
highlight: function(element, errorClass) {
$(element.form).find('label[for=' + element.id +
']').addClass(errorClass);
},
unhighlight: function(element, errorClass) {
$(element.form).find('label[for=' + element.id +
']').removeClass(errorClass);
}
});

and my html:

fieldset
  label for=prefix*Prefix:/label
  input id=prefix name=prefix type=text class=field /
/fieldset

fieldset
  label for=name*Name:/label
  input id=name name=name type=text class=field /
/fieldset

and I am using jquery 1.2.6 with jquery validation 1.4

When I submit with errors both labels get the errorClass attached
which is what I want. But when I fix the errors and submit again, the
labels disappear and it seems are getting a style=display;none
instead of running the unhighlight method. Also, if I put an alert
statement inside the unhighlight method it seems once you submit with
no errors each corrected field spits out the alert twice. Any ideas?
How do I get the unhighlight to remove the class instead of making the
label disappear?


[jQuery] jquery validation unhighlight issue

2008-11-05 Thread kedr

my js is as follows:

var validator = $('#myForm').validate({
onfocusout: false,
onkeyup: false,

rules: {
prefix: { required: true },
name: { required: true }
},

messages: {
prefix: { required: 'Please select a prefix' },
name: { required: 'Please provide your name' }
},

errorClass: 'formError',
highlight: function(element, errorClass) {
$(element.form).find('label[for=' + element.id +
']').addClass(errorClass);
},
unhighlight: function(element, errorClass) {
$(element.form).find('label[for=' + element.id +
']').removeClass(errorClass);
}
});

and my html:

fieldset
  label for=prefix*Prefix:/label
  input id=prefix name=prefix type=text class=field /
/fieldset

fieldset
  label for=name*Name:/label
  input id=name name=name type=text class=field /
/fieldset

and I am using jquery 1.2.6 with jquery validation 1.4

When I submit with errors both labels get the errorClass attached
which is what I want. But when I fix the errors and submit again, the
labels disappear and it seems are getting a style=display;none
instead of running the unhighlight method. Also, if I put an alert
statement inside the unhighlight method it seems once you submit with
no errors each corrected field spits out the alert twice. Any ideas?
How do I get the unhighlight to remove the class instead of making the
label disappear?