我目前正在研究jquery并且在验证使用方面存在问题。我为注册创建了一个代码,但是当我运行它时,没有任何反应,并且也没有出现错误。谁能帮助我?
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js" ></script>
<script type="text/javascript" scr="js/signup-form.js"></script>
<script>
$().ready(function () {
$("#registerForm").validate({
rules: {
email: {
required: true,
email: true
},
userName: {
required: true,
minLength: 8
},
password: {
required: true,
minlength: 8
},
passwordConfirmation: {
required: true,
equalTo: "#password"
}
},
messages: {
email: {
required: "This field can not be empty",
email: "Email address does not valid"
},
userName: {
required: "This field can not be empty",
minLength: "UserName must contain at least 8 charactors"
},
password: {
required: "This field can not be empty",
minLength: "Password must contain at least 8 charactors"
},
passwordConfirmation: {
required: "This field can not be empty",
equalTo: "Please enter the same password above"
}
}
});
});
</script>
<form id="registerForm">
<fieldset>
<div>
<p>
<label>Email</label>
<input type="email" value="@Model.Email" name="email" id="email" />
</p>
<p>
<label>Username</label>
<input tyep="text" value="@Model.UserName" name="username"/>
</p>
<p>
<label>Password</label>
<input type="password" value="@Model.Password" name="password"/>
</p>
<p>
<label>Confirm Password</label>
<input type="password" value="@Model.PasswordConfirmation" name="passwordConfirmation" />
</p>
</div>
</fieldset>
<p>
<input type="submit" vaule="Register" />
</p>
</form>
当我点击注册按钮时,没有任何反应,也没有错误。任何人都可以帮我解决这个问题吗? 顺便说一句,我使用visual studio MVC 5,这有什么问题吗? 感谢!!!
@edit:
我在hjsfiddle.net/5d1b50k6尝试了我的代码,它运行正常。但它仍然无法在我的电脑上工作。 mvc会影响那个??