未捕获的TypeError:无法读取未定义的属性“call” [英] Uncaught TypeError: Cannot read property 'call' of undefined

查看:171
本文介绍了未捕获的TypeError:无法读取未定义的属性“call”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个预先存在的表单,我正在尝试将jquery验证添加到包含:

I have a preexisting form which I'm trying to add jquery validation to containing :

<form id="form" method="POST" action="/title/">
    {% csrf_token %}
<input type="hidden" name="id" value="6">
<input type="hidden" name="custom_checkbox_Electronic_Signature_man" value="1">
                            <p> <span class="style9">First Name </span>
                              <input type="text" name="first_name" value="" size="20" class="style7"><span class="style9">
                            Last Name </span>
                              <input type="text" name="last_name" value="" size="20" class="style7"><span class="style9">

使用jquery验证器插件,我添加了:

Using the jquery validator plugin, I have added:

$('form').validate({
    rules: {
        first_name: {
            minlen: 3,
            maxlength: 15,
            required: true
        },
        last_name: {
            minlength: 3,
            maxlength: 15,
            required: true
        },
        email: {
          required: true,
          email: true
        },
         phone1: {
             required: true,
             phoneUS: true
          },
        phone2: {
             required: true,
             phoneUS: true
          },
            street: {
            required: true
          },
              city: {
            required: true
          },
              state: {
            required: true
          },
              zip: {
            zipcodeUS: true
          }

    },
    highlight: function(element) {
        $(element).closest('.style9').addClass('.style13');
        //$(element).addClass('.style13');
    },
    unhighlight: function(element) {
        $(element).closest('.style9').removeClass('.style13');
        //$(element).removeClass('.style13');
    },
    errorElement: 'span',
    errorClass: 'style13',
    errorPlacement: function(error, element) {
        if(element.parent('.input-group').length) {
            error.insertAfter(element.parent());
        } else {
            error.insertAfter(element);
        }
    }
});

我收到上面列出的错误。我做错了什么?

I'm getting the error listed above . What am I doing wrong?

推荐答案

用<$ c替换 minlen $ c> minlength ,它有效,没有 minlen 属性,所以调用内部失败

Replace minlen with minlength, and it works, there is no minlen property, so call fails internally

$('form').validate({
    rules: {
        first_name: {
            minlength: 3,  // <- here
            maxlength: 15,
            required: true
        },
        last_name: {
            minlength: 3,
            maxlength: 15,
            required: true
        },
   ..........

这篇关于未捕获的TypeError:无法读取未定义的属性“call”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆