简体   繁体   English

bassistance jQuery验证插件的愚蠢问题

[英]Silly problem with bassistance jquery validation plugin

The there guys. 那里的家伙。

I'm confused with a strange behavior of a simple page using bassistance jquery validation. 我对使用bassistance jquery验证的简单页面的奇怪行为感到困惑。 In short, I have two input fields, both marked as "required". 简而言之,我有两个输入字段,都标记为“必填”。 The problem is that it seems that the plugin is validation only the first field. 问题在于,似乎插件仅验证第一个字段。

This is the snippet of my test: 这是我的测试的片段:

<html>
 <head>
  <script type="text/javascript" src="[path to my app]/js/jquery-1.4.3.min.js"></script>
  <script type="text/javascript" src="[path to my app]/js/jquery.validate.min.js"></script>
 </head>

 <body>
  <form id="testForm">
   <input id="field1" type="text" class="required"/>
   <input id="field2" type="text" class="required"/>

   <button>Query</button>
  </form>

  <script type="text/javascript">
   $(document).ready(function() {
    $("#testForm").validate();
   });
  </script>
 </body>
</html>

When I click on the Query button, a (correctly shown) error message is presented to the first field, but not to the second one. 当我单击查询按钮时,一个错误消息(正确显示)显示在第一个字段中,而不显示给第二个字段。

Maybe one of you knows what I'm doing wrong here? 也许有人知道我在这里做错了吗?

Your input fields must have names: 您的输入字段必须具有名称:

<input id="field1" name="field1" type="text" class="required" />
<input id="field2" name="field2" type="text" class="required" />

And here's a working demo . 这是一个工作示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM