Quantcast

[validate] onkeyup for single field

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[validate] onkeyup for single field

simshaun

This question is in regards to the jQuery validation library
http://bassistance.de/jquery-plugins/jquery-plugin-validation/

Is it possible to turn off onkeyup for a singe field instead of the
entire form?
It'd be cool if I could just put onkeyup=false within the rules array
for that field.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [validate] onkeyup for single field

Jörn Zaefferer-2

Good question, and I don't yet have a good solution at hand.

One approach I'd try is to add your own keyup-handler to the input
field, as always cancel the event (return false). That way the event
doesn't get bubbled up to the parent form.

Jörn

On Thu, Jan 29, 2009 at 4:29 PM, simshaun <[hidden email]> wrote:
>
> This question is in regards to the jQuery validation library
> http://bassistance.de/jquery-plugins/jquery-plugin-validation/
>
> Is it possible to turn off onkeyup for a singe field instead of the
> entire form?
> It'd be cool if I could just put onkeyup=false within the rules array
> for that field.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [validate] onkeyup for single field

simshaun

I tried adding onkeyup="return false;" to the field.  Doesn't seem to
work though.

The solution I came up with is to add this in the config array.

onkeyup: function(element) {
    if ($(element).attr('name') != 'username') {
        $.validator.defaults.onkeyup.apply(this,arguments);
    }
}

It'd be much easier to have onkeyup: false in the rules array :) lol
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [validate] onkeyup for single field

paolold
Hello,

I was able to disable the validation for the keyup event of one single filed by adding a custom function which returns false for the keyup event of the input field:

$("#email").keyup(function() {
    return false;
 });

simshaun wrote
I tried adding onkeyup="return false;" to the field.  Doesn't seem to
work though.

The solution I came up with is to add this in the config array.

onkeyup: function(element) {
    if ($(element).attr('name') != 'username') {
        $.validator.defaults.onkeyup.apply(this,arguments);
    }
}

It'd be much easier to have onkeyup: false in the rules array :) lol
Loading...