如何从对象调用函数?

时间:2015-03-19 15:12:31

标签: jquery formvalidation-plugin

我使用formValidation编写登录表单验证。现在我想在我的脚本中调用此函数。如何调用form_login函数?

(function(){
  $.fn.validation = {
    form_login: function(form){
         $(form).formValidation({
                icon: {
                    valid: 'fa fa-check',
                    invalid: 'fa fa-remove',
                    validating: 'fa fa-refresh'
                },
            fields: {
                usernme: {
                    validators: {
                        notEmpty: {},
                    }
                },
                password: {
                    validators: {
                        notEmpty: {},
                    }
                },
                captcha: {
                    validators: {
                        notEmpty: {},
                    }
                }
            }
        });
    },
  };
 }());

1 个答案:

答案 0 :(得分:-1)

与您的代码类似的用法示例(更短):

$.fn.test={
    test_method: function(){alert('a');}
}

var div= "<div></div>";
$(div).test.test_method(); // it will output that alert