“对象不支持此属性或方法”错误 - JQuery .validate方法

时间:2014-03-21 12:33:08

标签: javascript php jquery html

我遇到了一些问题,我不知道如何解决它。在使用jquery-1.10.4时,我得到“对象不支持此属性或方法”错误。 .validate方法对我不起作用。请帮忙。

这是我的代码

的login.html

<html>

<head>
<link rel="stylesheet" type="text/css" href="design.css">
<script type="text/javascript">
</script>
<script type="text/javascript" src="jquery-1.11.0.min.js"></script>
<script src="jquery-1.11.0.min.js"></script>
<script src="jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.min.js"></script>
<script src="loginBouncy.js"></script>
<script src="modal.js"></script>
<script src="validate.js"></script>
<script src="jquery.validate.min"></script>

</head>
<div id='mask' class='close_modal'></div>

<div id="signup" class='modal_window'>



<img id="pane1" src="pane1.png"/>
<p id="label">SignUp</p>
<p id="label1">Personal&nbsp;Information</p>
<p id="label2">Account</p>
<p id="label3">Verification</p>
<hr id="hr1"/>
<form id="mainform" name="mainform" method="post" action="SignUp2.php">
<input type="text" name="data[]" id="fname" name="fname" placeholder="First Name"/>
<input type="text" name="data[]" id="lname" name="lname" placeholder="Last Name"/>
<input type="text" name="data[]" id="mname" name="mname" placeholder="M.I."/>
<input type="text" name="data[]" id="sadd"  name="sadd" placeholder="Street"/>
<input type="text" name="data[]" id="tadd"  name="tadd" placeholder="Town/City"/>
<input type="text" name="data[]" id="padd"  name="padd" placeholder="Province/State"/>
<input type="text" name="data[]" id="user2" name="user2" placeholder="Your Username"/>
<input type="password" name="data[]" id="pass2" name="pass2" placeholder="Your Password">
<input id="captcha" name="captcha" type="text" name="captcha" placeholder="Insert Captcha">
<img id="imgcaptcha" src="captcha.php" /><br>
<input type="text" name="data[]" id="email" name="email" placeholder="Your Email"/>
<input type="button" id="btnSignUp"  placeholder="" onclick="error2()"/>
</input>
</form>

</div>
</html>

validate.js

$(document).ready(function(){
$('#signup form').validate({
rules:{
    name:{
        required:true
    },
    email:{
        required:true,
        email:true
    },
    fname:{
        required:true
    },
    lname:{
        required:true
    },
    fname:{
        required:true
    },
    mname:{
        required:true
    },
    sadd:{
        required:true
    },
    tadd:{
        required:true
    },
    padd:{
        required:true
    },
    pass2:{
        required:true,
        minlength:4
    },
    user2:{
        required:true
    },
    captcha:
    {
        required:true
    },
    success:function(label){
        label.text('OK!').addClass('valid');
    }
    }
});
});

2 个答案:

答案 0 :(得分:3)

看起来你在脚本src中错过了.js

<script src="jquery.validate.min.js"></script>

答案 1 :(得分:1)

您在jQuery验证插件名称中缺少.js,它应该是:

<script src="jquery.validate.min.js"></script>
<!------------------------------^^^ add .js here -->