使用jquery在表单顶部显示错误消息

时间:2014-02-25 17:33:24

标签: jquery

我需要知道如何使用jquery在表单顶部显示错误消息 即时通讯使用jquery / 1.10.2 / jquery.min.js和jquery-form-validator / 2.1.38 / jquery.form-validator.min.js 所以,如果有可能帮助我那将是伟大的 这是我的表单使用jquery表单验证器验证的示例

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-form-validator/2.1.38/jquery.form-validator.min.js"></script>

 <body>


    <form id="form1" name="form1" method="POST" action="">
      <table width="325" border="1">



        <tr>
          <td>Pseudo</td>
          <td>
          <input name="user" data-validation="length alphanumeric" 
             data-validation-length="3-12" data-validation-error-msg="The user name has to be an alphanumeric value between 3-12 characters" />
     </td>
        </tr>
        <tr>
          <td>Password</td>
          <td>
          <input type="password" name="password" data-validation="strength" 
             data-validation-strength="2" required>
       </td>
        </tr>
        <tr>
          <td>Password confirmation</td>
          <td>
            <input type="password" name="Password_confirmation" data-validation="confirmation" required/>
          </td>
      </table>
    </form>


    <script>

      $.validate({
        modules : 'location, date, security, file',
        onModulesLoaded : function() {
          $('#country').suggestCountry();
        }
      });

      // Restrict presentation length
      $('#presentation').restrictLength( $('#pres-max-length') );

    </script>
    <script>
    $("#form1").validate({
      errorLabelContainer: "#messageBox",
      wrapper: "li",
      submitHandler: function() { alert("Submitted!") }
    });
    </script>

0 个答案:

没有答案