JQuery 验证让我抓狂?
拜托,某人,任何人。最近几天我一直遇到 JQuery 验证问题。我尝试过各种各样的事情,甚至有几次从头开始。这是我使用下面的链接作为参考的最新迭代。我做错了什么?!
它到达这一行并停止: var validator = new jQueryValidatorWrapper("#formRegister", Rules, messages);
http://www.codeproject.com/KB/ajax/jQueryValidateExample.aspx
HTML
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="register.aspx.cs" Inherits="Website.Pages.register" %>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" type="text/javascript"></script>
<link href="../Styles/registration.css" rel="stylesheet" type="text/css" />
<script src="../Scripts/val.js" type="text/javascript"></script>
<script src="../Scripts/_plugins/validate.js" type="text/javascript"></script>
<div class="page">
<form runat="server" id="formRegister"><div>
<span id="Run">Username</span><br />
<asp:TextBox runat="server" ID="rUsername" name="rUsername" /></div>
<div><span id="Re">Email</span><br />
<asp:TextBox runat="server" ID="rEmail" name="rEmail" /></div>
<div><span id="Rce">Confirm Email</span><br />
<asp:TextBox runat="server" ID="rConfirmEmail" /></div>
<div><span id="Rpw">Password</span><br />
<asp:TextBox runat="server" ID="rPassword" TextMode="Password" /></div>
<div><span id="Rcpw">Confirm Password</span><br />
<asp:TextBox runat="server" ID="rConfirmPassword" TextMode="Password" Class="required" /></div>
<div id="buttonRegister"><input type="button" id="rRegister" value="Register" /></div>
</form>
</div>
查询
$(function () {
// register.aspx
var rules = {
rUsername: {
required: true,
minlength: 3
},
rEmail: {
required: true,
email: true
}
};
var messages = {
rUsername: {
required: "- Required",
minlength: " - Minimum Length: 3"
},
rEmail: {
required: "- Required",
email: "- Incorrect Format"
}
};
$("#rRegister").click(function () {
var validator = new jQueryValidatorWrapper("#formRegister", rules, messages);
if (!validator.validate())
return;
alert("Validation Success!");
});
});
Please, someone, anyone. I've been having JQuery validation issues for the last few days. I've tried all kinds of things and even started from scratch a few times. This is my latest iteration using the link below as reference. What am I doing wrong?!
It gets to this line and stops: var validator = new jQueryValidatorWrapper("#formRegister", rules, messages);
http://www.codeproject.com/KB/ajax/jQueryValidateExample.aspx
HTML
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="register.aspx.cs" Inherits="Website.Pages.register" %>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" type="text/javascript"></script>
<link href="../Styles/registration.css" rel="stylesheet" type="text/css" />
<script src="../Scripts/val.js" type="text/javascript"></script>
<script src="../Scripts/_plugins/validate.js" type="text/javascript"></script>
<div class="page">
<form runat="server" id="formRegister"><div>
<span id="Run">Username</span><br />
<asp:TextBox runat="server" ID="rUsername" name="rUsername" /></div>
<div><span id="Re">Email</span><br />
<asp:TextBox runat="server" ID="rEmail" name="rEmail" /></div>
<div><span id="Rce">Confirm Email</span><br />
<asp:TextBox runat="server" ID="rConfirmEmail" /></div>
<div><span id="Rpw">Password</span><br />
<asp:TextBox runat="server" ID="rPassword" TextMode="Password" /></div>
<div><span id="Rcpw">Confirm Password</span><br />
<asp:TextBox runat="server" ID="rConfirmPassword" TextMode="Password" Class="required" /></div>
<div id="buttonRegister"><input type="button" id="rRegister" value="Register" /></div>
</form>
</div>
JQUERY
$(function () {
// register.aspx
var rules = {
rUsername: {
required: true,
minlength: 3
},
rEmail: {
required: true,
email: true
}
};
var messages = {
rUsername: {
required: "- Required",
minlength: " - Minimum Length: 3"
},
rEmail: {
required: "- Required",
email: "- Incorrect Format"
}
};
$("#rRegister").click(function () {
var validator = new jQueryValidatorWrapper("#formRegister", rules, messages);
if (!validator.validate())
return;
alert("Validation Success!");
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
上面的评论是正确的。试试这个:
The comments above are correct. Try this: