2014-09-06 74 views
0

?我使用jquery驗證插件來驗證我的表單,因爲eveything是好的形式現在不工作,它曾經工作以前可以任何一個告訴我什麼是錯的代碼jquery驗證插件現在不工作在我的代碼

這裏是我的代碼

<head> 
     <meta charset="utf-8"> 
     <title>jQuery validation plug-in - main demo</title> 
     <link rel="stylesheet" href="css/screen.css" /> 
     <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> 
     <script src="http://jquery.bassistance.de/validate/jquery.validate.js"></script> 
     <script> 
//alert("Hi"); 
     </script> 
     <script> 

$()準備就緒(函數(){//警報( 「在準備好了」); // 驗證評論表單當它處於

 $("#commentForm").validate({ 
      rules :{ 
       UMcustreceiptname:"required", 
       UMcustemail:{ 
        required:true, 
        email:true 
       }, 
       UMname:"required", 
       // street:"required", 
       // city:"required", 
       UMzip:{ 
        required: true, 
        number:true, 
        minlength:4, 
        maxlength: 6 
       }, 
       //      UMcardtype: { 
       //       required: { 
       //        depends: function(element) { 
       //         return $("#UMcardtype").val() == ''; 
       //        } 
       //       } 
       //      }, 
       UMexpir:{ 
        required: true, 
        number:true, 
        minlength:4, 
        maxlength: 4 
       }, 
       //       UMcvv2:{ 
       //       required: true, 
       //       number:true, 
       //       minlength:3, 
       //       maxlength: 3 
       //      }, 
       UMcard: { 
        required: true, 
        number:true, 
        minlength:16, 
        maxlength:16 


       } 
      }, 
      messages: { 
       cardtype: 'Please select a <b>card type</b>.' 
      } 



     }); 



    }); 
     </script> 
<style type="text/css"> 
    #commentForm { width: 500px; } 
    #commentForm label { width: 250px; } 
    #commentForm label.error, #commentForm input.submit { margin-left: 253px; } 
    #signupForm { width: 670px; } 
    #signupForm label.error { 
     margin-left: 10px; 
     width: auto; 
     display: inline; 
    } 
    #newsletter_topics label.error { 
     display: none; 
     margin-left: 103px; 
    } 
</style> 

    </head> 
    <body> 
     <div id="main"> 
      <div class="wowio_total" style="background-color:#fdf6f1;"> 
       <table width="700" align="center"> 
        <tr> 
         <td align="center"> 
          <h2 style="background-color:#f17122; width:500px; height:30px; line-height:30px; color:#FFFFFF;">PAYMENT GATEWAY</h2> 
          <form class="cmxform" id="commentForm" action="http://www.domainname.com/index.php/bookInfo/pay" method="POST" style="background-color:#faddcb; border:1px dotted #f17122;"> 
           <input id="bookId" name="bookId" type="hidden" value="<?php echo $bookId; ?>"/> 
           <input id="readerId" name="readerId" type="hidden" value="<?php echo $readerId; ?>"/> 

           <input id="authorId" name="authorId" type="hidden" value="<?php echo $authorId; ?>"/> 
           <input id="amount" name="amount" type="hidden" value="<?php echo $amount; ?>"/> 
           <fieldset style="border:1px solid #fbcfb3; "> 
            <?php if (!empty($message)) { ?> 
             <div class="err_msg">RESULT : <?php echo $message; ?></div> 
            <?php } ?> 
            <p class="tbrcr"> 
             <label for="UMcustreceiptname" style="text-align:left; margin-left:27px;">Name :</label> 
             <input id="UMcustreceiptname" name="UMcustreceiptname" value="" type="text" class="tbrcr"/> 
            </p> 
            <p class="tbrcr" style="margin-left:27px;"> 
             <label for="UMcustemail" style="text-align:left;">E-Mail :</label> 
             <input id="UMcustemail" type="UMcustemail" value="" name="UMcustemail" class="tbrcr"/> 
            </p> 
            <p class="tbrcr" style="margin-left:27px;"> 
             <label for="street" style="text-align:left;">Street :</label> 
             <input id="street" type="text" name="street" class="tbrcr"/> 
            </p> 
            <p class="tbrcr" style="margin-left:36px;"> 
             <label for="city" style="text-align:left;">City :</label> 
             <input id="city" type="text" name="city" class="tbrcr"/> 
            </p> 
            <p class="tbrcr" style="margin-left:10px;"> 
             <label for="UMzip" style="text-align:center;">Zip Code :</label> 
             <input id="UMzip" type="text" name="UMzip" value="" class="tbrcr"/> 
            </p> 
<!--         <p class="tbrcr" style="margin-left:5px;"> 
             <label for="UMcardtype" style="text-align:center;" >Card Type :</label> 
             <select class="menu_br_card_type" id="UMcardtype" name="UMcardtype" id="cardtype"> 
             <option value="" selected="selected">..... Select One .....</option> 
             <option value="visa">Visa</option> 
             <option value="mastercard">Master Card</option> 
             <option value="amex">Amex</option> 
             </select> 
            </p>--> 
            <p class="tbrcr" style="margin-left:-10px;"> 
             <label for="UMcard" style="text-align:left;">Card Number :</label> 
             <input id="UMcard" name="UMcard" value="" type="text" class="tbrcr"/> 
            </p> 
            <p class="tbrcr"> 
             <label for="UMexpir" style="text-align:center;">Expiry Date :</label> 
             <input id="UMexpir" name="UMexpir" type="text" value="" class="tbrcr"/> 
            </p> 
            <!-- <p class="tbrcr"> 
             <label for="name" style="text-align:left; margin-left:27px;">Name on Card :</label> 
             <input id="UMname" name="UMname" type="text" class="tbrcr"> 
            </p>--> 
            <p class="tbrcr"> 
             <label for="UMcvv2" style="text-align:left; margin-left:27px;">CVV2 :</label> 
             <input id="UMcvv2" name="UMcvv2" value="" type="text" class="tbrcr"/> 
            </p>   

            <p class="tb_btn"> 
             <input class="submit" type="submit" id="submit" value="Submit" class="tb_btn"/> 
            </p> 
           </fieldset> 
          </form> 
         </td> 
        </tr> 
       </table> 
      </div> 
     </div> 
    </body> 
</html> 
+0

任何控制檯錯誤? – 2014-09-06 05:50:21

+0

不,它用於正常工作,不工作 – 2014-09-06 05:57:04

+0

URL'http:// jquery.bassistance.de/validate/jquery.validate.js'不加載。 – 2014-09-06 06:11:14

回答

0

試試這個JSFiddle:http://goo.gl/rNDEHe。我已經創建了你的例子,它的工作。

+0

你的答案應該包括解決問題的代碼,或者解釋你已經做了什麼來解決它。 – Ryley 2014-09-08 15:19:07