jQuery验证表单不起作用

时间:2010-01-23 15:05:11

标签: jquery forms jquery-validate

MY .js档案:

 //rounded corners
        $(document).ready(function() {
            $("#topbar").corner("bl br 5px");
            $("#mainbar").corner("5px");
            $("#sidebar").corner("5px");
            $("#bottombar").corner("5px");
        });
    //form
        $(document).ready(function(){
            $("#commentForm").validate({
                rules: {
                    FieldData0: {
                        required: true
                    },
                    FieldData1: {
                        required: true,
                        email: true
                    },
                    FieldData2: {
                        required: true
                    }
                },
                messages: {
                    FieldData0: {
                        required: "* Required"
                    },
                    FieldData1: {
                        required: "* Required",
                        minlength: "* 2 Characters Required."
                    }
                }   
            });
        })

我的.html文件:

<div id="mainbar">
        <form id="commentForm" method="post" action="http://www.emailmeform.com/fid.php?formid=254816">
        <h2>Contact Form</h2>
        <p>
            <label for="name">Your Name</label>
            <input type="text"  id="name" name="FieldData0" />
        </p>
        <p>
            <label for="email">Your Email</label>
            <input type="text"  id="email" name="FieldData1" />
        </p>
        <p>
            <label for="message">Your Message</label>
            <textarea type="text" id="message" name="FieldData2"></textarea>
        </p>
        <p>
            <input id="button" type="submit" value="Submit">
        </p>
        </form>
    </div>

直播示例:

http://weedcl.zxq.net/form.html

1 个答案:

答案 0 :(得分:2)

看完演示后,我注意到你的jquery插件丢失了(至少在html中)。尝试添加:

<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.6/jquery.validate.js" />

在头文件中加入custom.js之前。表单验证是通过插件提供的,而不是由jQuery本身提供的。

另外,我注意到角落插件也不存在 - download it并将其包含在头部。

您应该对jQuery png fix执行相同操作。