你需要 jQuery 库、jQuery 验证插件和元插件。
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.5.5/jquery.validate.min.js"></script>
<script type="text/javascript" src="http://jquery-multifile-plugin.googlecode.com/svn-history/r16/trunk/jquery.MetaData.js"></script>
<form id="form1" runat="server">
<asp:TextBox ID="txtEmail" runat="server" class="{required:true, email:true,messages:{required:'required.',email: 'invalid email!' }}"></asp:TextBox>
<!-- ... -->
<asp:Button ID="btnSubmit" runat="server" Text="submit" />
</form>
validate()
在 asp.net 表单上使用jQuery 验证插件。
<script type="text/javascript">
$(document).ready(function () {
$("#form1").validate();
});
</script>