jQuery validation onblur

前端 未结 6 1230
迷失自我
迷失自我 2020-12-01 12:26

I am trying to get the jQuery validation working on a webpage I am creating. I have about 6 different fieldsets that contain the page\'s details. I am using this as I am hid

相关标签:
6条回答
  • 2020-12-01 12:35

    I can't see anything in the docos that can do that. The only other way i can think of doing it is.

    $('#field1, #field2, #field3').blur(function(){
        validator.validate()
    });
    
    0 讨论(0)
  • 2020-12-01 12:45

    Thia code will not fire validation onkeyup, but on blur "lost focus" the validation will be fire, as will once the user starts to edit the field, validation message will disappear. find more interesting other customization on this ref: https://jqueryvalidation.org/category/plugin/

    $('#frm').validate({
                onkeyup: false,
                focusCleanup: true
            });
    
    0 讨论(0)
  • 2020-12-01 12:48

    Diver Dan was right

    $('form').validate({
        onfocusout: function (element) {
            $(element).valid();
        },
        rules: {
            name: 'required',
            from: 'required'
    
        },
        messages: {
            name: 'Please enter your firstname',
            from: 'Please enter where are you from'
        }
    });
    
    0 讨论(0)
  • 2020-12-01 12:49

    Just set on onkeyup = false

    $('form').validate({
        rules: {
            name: 'required',
            from: 'required'
    
        },
          onkeyup: false
           ,
        messages: {
            name: 'Please enter your firstname',
            from: 'Please enter where are you from'
        }
    });
    
    0 讨论(0)
  • 2020-12-01 12:51

    try:

    onkeyup: function (element, event) {
    
     $(element).valid();
     // your code
    }
    
    0 讨论(0)
  • 2020-12-01 12:52

    You can also use the element call of the validator.

       $('form').validate({
            onfocusout: function(element) {
               this.element(element);
            },
            rules: {
                name: 'required',
                from: 'required'
    
            },
            messages: {
                name: 'Please enter your firstname',
                from: 'Please enter where are you from'
            }
        });
    
    0 讨论(0)
提交回复
热议问题