发表评论
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="frmAuto.aspx.cs" Inherits="StudyJQuery.jsAuto.frmAuto" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="../js/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>
<style type="text/css">
.diverror
{
border: 1px dashed #FF0000;
background-color: #CCCCCC;
margin: 0px;
padding: 0px;
font-size: 12px;
line-height: 25px;
}
.divright
{
font-size: 12px;
line-height: 25px;
background-color: #FFFFFF;
margin: 0px;
padding: 0px;
border-top-style: none;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
}
</style>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
// $("form input[class],select[class]").each(function(index, e) {
// alert(index + e.id);
// });
$("form input[class],select[class]").blur(function() {
//alert($(this).val());
var id = $(this).attr("id");
var $ErrorMessage; //= $("<div id = err'" + id + "'></div>");
$ErrorMessage = $(this).parent().find("#err" + id);
//alert(typeof ($ErrorMessage[0]));
// if (typeof ($("#jd_shadow")[0]) == "undefined") {
if (typeof ($ErrorMessage[0]) == "undefined") {
$ErrorMessage = $("<div id = err" + id + " ></div>");
$ErrorMessage.insertAfter($(this));
}
if ($(this).val() == "" || $(this).val() == null) {
$ErrorMessage.removeAttr("class").attr("class", "diverror");
}
else {
$ErrorMessage.removeAttr("class").attr("class", "divright");
}
$ErrorMessage.removeAttr("class").attr("class", "divright").attr("class", "diverror");
$ErrorMessage.text(id + "出错!");
//$(this).parent().remove("#err" + id);
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div class="diverror">
<table>
<tr>
<td>
用户名
</td>
<td>
<asp:TextBox ID="txtUserID" runat="server" CssClass="1"></asp:TextBox>
</td>
</tr>
<tr>
<td>
密码
</td>
<td>
<asp:TextBox ID="txtUserPwd" runat="server" CssClass="2"></asp:TextBox>
</td>
</tr>
<tr>
<td>
手机号码
</td>
<td>
<asp:TextBox ID="txtUserTel" runat="server" CssClass="3"></asp:TextBox>
</td>
</tr>
<tr>
<td>
EMAIL
</td>
<td>
<asp:TextBox ID="txtUserEMail" runat="server" CssClass="4"></asp:TextBox>
</td>
</tr>
<tr>
<td>
性别
</td>
<td>
<asp:DropDownList ID="drpUserSex" runat="server" CssClass="5">
<asp:ListItem Value="0">请选择</asp:ListItem>
<asp:ListItem Value="1">男</asp:ListItem>
<asp:ListItem Value="2">女</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="btnSubmit" runat="server" Text="提交" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。