开发者

Jquery validation plugin (bassistance.de) and validation on tab for empty fields

开发者 https://www.devze.com 2023-02-09 17:30 出处:网络
I see a duplicate question about this but with no accepted answers: jQuery Validation PlugIn : Forcing Validation on empty Field

I see a duplicate question about this but with no accepted answers: jQuery Validation PlugIn : Forcing Validation on empty Field

There is a comment on the linked post that validation on tabbing won't work without editing the plugin开发者_开发知识库. Does anybody have any solutions or workaround to get the validation plugin to fire on tabbing through empty fields?

I've tried the event option, passing in 'blur', 'keydown','keyup', etc.

Has anyone come up with a patch or workaround?

Thanks!


Ah, I see now, you just need to call valid() on an element and all children inputs will be validated.

I decided to add validation to the blur event and tab

    $("input").blur(function() {
        $(this).valid();
    })
    $("input").keydown(function(e) {
        var code = (e.keyCode ? e.keyCode : e.which);
        if(code == 9) { //Enter keycode
            $(this).valid();
        }
    })
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号