Jquery验证插件现在在我的代码中不起作用

时间:2014-09-06 05:49:35

标签: jquery validation

?我使用jquery验证插件来验证我的表单,因为eveything是好的表单现在不能正常工作,以前可以工作任何人告诉我代码中有什么错误

这是我的代码

 <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>

$()。ready(function(){// alert(&#34;准备就绪&#34;);             //在提交评论表时验证

        $("#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>

1 个答案:

答案 0 :(得分:0)

试试这个JSFiddle:http://goo.gl/rNDEHe。我创建了你的例子,它正在运作。