【问题标题】:Trying to give the field's ID to the JQuery instead of its Name试图将字段的 ID 提供给 JQuery 而不是其名称
【发布时间】:2015-04-10 14:40:26
【问题描述】:

我试图通过其 ID 而不是名称来传递输入字段。如果我将输入字段的名称放在下面,它就可以工作。

$('#textName_insert'):

但是放了ID之后,ID就不行了。

 $(document).ready(function () {

    $('#myform').validate({ // initialize the plugin
        rules: {
            $('#textName_insert'): {
                required: true,
                email: true
            },
            $('#textadr1_insert'): {
                required: true,
                minlength: 5
            }
        }
    });

  });


<form id="insertForm" class="form-horizontal" method="post" action="InsertAgentSrvlt">
          <fieldset id="modal_form">                  
            <!-- Text input-->
            <div class="form-group">
              <label class="col-md-4 control-label" for="textinput">Name:</label>
              <div class="col-md-8">
                <input id="textName_insert" name="textName" type="text" placeholder="" class="form-control input-md"/>
              </div>
            </div>

【问题讨论】:

    标签: jquery html forms validation


    【解决方案1】:

    Key 是 jQuery 验证插件中元素的名称。您必须提供名称,而不是 ID。

    阅读this

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-08
      • 1970-01-01
      • 2015-04-07
      • 2015-12-03
      • 2021-08-11
      • 2019-10-24
      • 1970-01-01
      • 2015-03-04
      相关资源
      最近更新 更多