簡體   English   中英

為什么我的Jquery Validate無法正常工作?

[英]Why isn't my Jquery Validate working?

我已經做了一些在線研究,找不到解決方案。 我正在使用Jquery Validator插件來驗證我的登錄和注冊表格。 我已經對注冊表格進行了編碼,它完全可以正常工作。 但是,我以完全相同的方式對日志進行編碼,因此無法正常工作。 當我有空白字段時,不顯示任何消息,並且允許提交表單。

登錄

<html>
<head>
 <link type="text/css" rel="stylesheet" href="../skin/frontend/css/styles.css" media="all"> 
 <?php include('../js/jquery.js'); ?>
 <script src="//code.jquery.com/jquery-1.10.2.js"></script>
 <script src="../js/validator.js"></script>
 <script src="../js/sign-in.js"></script>
</head>
<body>
    <div class="wrapper">
        <div class="header"><?php include('../app/views/frontend/header.php'); ?></div>
        <div class="body-container">
                Sign in <br>
                <form method="post" action="../account/signin/sign-in.php" id="signin"> 
                <input type ='text'placeholder='Username' name="usernamesignin" id="usernamesignin" ><br>
                <br>
                <input type='text' onfocus="this.type='password'" placeholder='Password' name="passwordsignin" id="passwordsignin"><br>
                <br>
                <input type="submit" value="Log In">
                </form>
                </div>
    </div>  
    </body>
</html>  

Sign.in

$(document).ready(function(){
 $("#signin").validate({
  rules: {
     usernamesignin: {
        required: true
           },
           passwordsignin:{
         required: true,
         minlength:6
         }
            },
           messages: {
                 username: {
        required: "Please Enter A Username"
           }
  }
     });
     });

我想念什么嗎? 這應該很簡單。

另外,我在console.log中注意到,我的注冊頁面未引發任何錯誤,但是我的登錄頁面顯示:“未捕獲的TypeError:無法讀取未定義的屬性'msie'”

不知道這是否是問題。

提前致謝!

得到它了! 輸入表單操作和表單ID。問題已解決!

通過執行以下操作,我得到了您的驗證:

  1. 刪除行"<?php include('../js/jquery.js'); ?>" 您不應有兩個對jQuery的引用
  2. 將以下行編輯為<script src="https://code.jquery.com/jquery-1.10.2.js"></script> 您缺少協議https:

按照這個問題 ,您應該能夠在沒有協議的情況下定義URI,但是在這種情況下,當鏈接到code.jquery.com CDN時,它不起作用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM