<i id='Xqir1'><tr id='Xqir1'><dt id='Xqir1'><q id='Xqir1'><span id='Xqir1'><b id='Xqir1'><form id='Xqir1'><ins id='Xqir1'></ins><ul id='Xqir1'></ul><sub id='Xqir1'></sub></form><legend id='Xqir1'></legend><bdo id='Xqir1'><pre id='Xqir1'><center id='Xqir1'></center></pre></bdo></b><th id='Xqir1'></th></span></q></dt></tr></i><div id='Xqir1'><tfoot id='Xqir1'></tfoot><dl id='Xqir1'><fieldset id='Xqir1'></fieldset></dl></div>

    <tfoot id='Xqir1'></tfoot>
    <legend id='Xqir1'><style id='Xqir1'><dir id='Xqir1'><q id='Xqir1'></q></dir></style></legend>
      • <bdo id='Xqir1'></bdo><ul id='Xqir1'></ul>
      1. <small id='Xqir1'></small><noframes id='Xqir1'>

        如何使用 jquery 验证插件验证名称中带有点的输入字段?

        时间:2023-06-14
          <bdo id='vVeVl'></bdo><ul id='vVeVl'></ul>

              <i id='vVeVl'><tr id='vVeVl'><dt id='vVeVl'><q id='vVeVl'><span id='vVeVl'><b id='vVeVl'><form id='vVeVl'><ins id='vVeVl'></ins><ul id='vVeVl'></ul><sub id='vVeVl'></sub></form><legend id='vVeVl'></legend><bdo id='vVeVl'><pre id='vVeVl'><center id='vVeVl'></center></pre></bdo></b><th id='vVeVl'></th></span></q></dt></tr></i><div id='vVeVl'><tfoot id='vVeVl'></tfoot><dl id='vVeVl'><fieldset id='vVeVl'></fieldset></dl></div>
                <tbody id='vVeVl'></tbody>

                  <tfoot id='vVeVl'></tfoot>

                  <small id='vVeVl'></small><noframes id='vVeVl'>

                  <legend id='vVeVl'><style id='vVeVl'><dir id='vVeVl'><q id='vVeVl'></q></dir></style></legend>
                  本文介绍了如何使用 jquery 验证插件验证名称中带有点的输入字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 这个 jquery 验证插件

                  <s:textfield cssClass="form-control input-default" name="contest.title" id="title" placeholder="Enter Title"
                                               />
                  

                  验证对此不起作用,但如果我将名称更改为 title - 验证有效.

                  Validation doesn't work for this, but if I change the name to title - validation works.

                  我尝试搜索,但找不到验证名称中带有 . 的字段的方法.

                  I tried searching, but couldn't find a means to validate fields with a . in their name.

                  请帮忙

                  更新

                  脚本

                  <script type="text/javascript">
                              jQuery(document).ready(function() {
                                  jQuery("#contestform").validate({
                                      submitHandler: function(form) {
                  //                        return false;  // block the default submit action
                                      },
                                      rules: {
                                          title: {
                                              required: true
                                          },
                                          link: {
                                              required: true
                                          },
                                          startdt: {
                                              required: true
                                          },
                                          enddt: {
                                              required: true
                                          },
                                          descr: {
                                              required: true
                                          },
                                      },
                                      messages: {
                                          title: "Please enter a title",
                                          link: "Please enter the sponser redirection link",
                                          startdt: "Please select start date",
                                          enddt: "Please select end date",
                                          descr: "Please enter description"
                                      }
                                  });
                              });
                          </script>
                  

                  表格的一部分

                  <form action="" enctype="multipart/form-data" method="post" id="contestform">
                              <s:hidden name="option" value="option"/>
                              <s:hidden name="contest.idcontest"/>
                              <div class="form-group">
                                  <label for="title">Title</label>
                                  <s:textfield cssClass="form-control input-default" name="contest.title" id="title" placeholder="Enter Title"
                                               />
                              </div>
                  

                  推荐答案

                  你需要把字段名放在qoutes中.来自 插件文档

                  You need to put the field names in qoutes. From the plugin documentation

                  名称复杂的字段(括号、点)

                  Fields with complex names (brackets, dots)

                  当你有一个像 user[name] 这样的 name 属性时,确保把引号中的名称.一般准则中的更多详细信息.

                  When you have a name attribute like user[name], make sure to put the name in quotes. More details in the General Guidelines.

                  链接参考中的示例:

                  $("#myform").validate({
                    rules: {
                      // no quoting necessary
                      name: "required",
                      // quoting necessary!
                      "user[email]": "email",
                      // dots need quoting, too!
                      "user.address.street": "required"
                    }
                  });
                  

                  这篇关于如何使用 jquery 验证插件验证名称中带有点的输入字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:struts2 jquery ajax 和客户端验证不能一起工作 下一篇:打开标签的数量限制

                  相关文章

                  <small id='oJQ4r'></small><noframes id='oJQ4r'>

                    <tfoot id='oJQ4r'></tfoot>
                      <bdo id='oJQ4r'></bdo><ul id='oJQ4r'></ul>

                    <legend id='oJQ4r'><style id='oJQ4r'><dir id='oJQ4r'><q id='oJQ4r'></q></dir></style></legend>
                      <i id='oJQ4r'><tr id='oJQ4r'><dt id='oJQ4r'><q id='oJQ4r'><span id='oJQ4r'><b id='oJQ4r'><form id='oJQ4r'><ins id='oJQ4r'></ins><ul id='oJQ4r'></ul><sub id='oJQ4r'></sub></form><legend id='oJQ4r'></legend><bdo id='oJQ4r'><pre id='oJQ4r'><center id='oJQ4r'></center></pre></bdo></b><th id='oJQ4r'></th></span></q></dt></tr></i><div id='oJQ4r'><tfoot id='oJQ4r'></tfoot><dl id='oJQ4r'><fieldset id='oJQ4r'></fieldset></dl></div>