问题是这样的:我有一个详细页,修改和增加都在这个页面,其中有一个车牌号,我用的Ajax方式实现重复验证。但是问题是:现在修改也会报告车牌号重复,我该怎么办?
我在list页穿过来一个参数,这是detail页,ajax处理页是另一个页面
<script type="text/javascript"> var xhr; //function createXMLHttpRequest1() { // alert(">>>"); //} function createXMLHttpRequest() { if (window.ActiveXObject) {//如果是IE浏览器 return new ActiveXObject("Microsoft.XMLHTTP"); } else if (window.XMLHttpRequest) {//非IE浏览器 return new XMLHttpRequest(); } } //function createXmlHttpRequest() { // if (window.XMLHttpRequest) { // xmlHttp = new XMLHttpRequest(); // if (xmlHttp.overrideMimeType) { // xmlHttp.overrideMimeType("text/xml"); // } // } // else if (window.ActiveXObject) { // try { // xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); // } // catch (e) { // xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); // } // } // if (!xmlHttp) { // window.alert("你的浏览器不支持创建XMLhttpRequest对象"); // } // return xmlHttp; //} function userExists(CarNum) { if (CarNum != "") { //请求字符串 var url = "TC_Maintenance.aspx?CarNum=" + CarNum + '&_dc=' + new Date().getTime(); // 1. 创建XMLHttpRequest组件 xhr = createXMLHttpRequest(); // 2. 设置回调函数 xhr.onreadystatechange = readyDo; // 3. 初始化XMLHttpRequest组件 xhr.open("GET", url, true); // 4. 发送请求 xhr.send(null); } } function readyDo() { if (xhr.readyState == 4) { if (xhr.status == 200) { var b = xhr.responseText; if (b == "true") { document.getElementById("mess_double").style.display = "inline"; } else { document.getElementById("mess_double").style.display = "none"; } } } } </script> </head> <body> <form id="form1" runat="server" defaultbutton="btnAdd"> <asp:ScriptManager ID="smDetail" runat="server" EnablePartialRendering="true"> </asp:ScriptManager> <div class="maincontent"> <asp:UpdatePanel ID="uplDetail" runat="server"> <ContentTemplate> <div class="panel"> <div class="title">明细</div> <div class="content"> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="smartGrid2"> <tr> <th width="13%" align="left">车牌号:</th> <td width="37%"> <asp:TextBox ID="txtCarNum" runat="server" MaxLength="15" onblur="userExists(this.value) "/> <asp:RequiredFieldValidator runat="server" ID="CarNum_Null_Check" ControlToValidate="txtCarNum" ErrorMessage="“车牌号”不能为空" Display="None" Height="5px" Width="5px" /> <span class="RequiredWarningStyle" runat="server" id="spCarNum">*</span> <span id="mess_double" style="display: none; color: Red">该车牌号已存在,请重新输入</span> </td> </tr>
<script type="text/javascript">
var xhr;
//function createXMLHttpRequest1() {
// alert(">>>");
//}
function createXMLHttpRequest() {
if (window.ActiveXObject) {//如果是IE浏览器
return new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {//非IE浏览器
return new XMLHttpRequest();
}
}
//function createXmlHttpRequest() {
// if (window.XMLHttpRequest) {
// xmlHttp = new XMLHttpRequest();
// if (xmlHttp.overrideMimeType) {
// xmlHttp.overrideMimeType("text/xml");
// }
// }
// else if (window.ActiveXObject) {
// try {
// xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
// }
// catch (e) {
// xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
// }
// }
// if (!xmlHttp) {
// window.alert("你的浏览器不支持创建XMLhttpRequest对象");
// }
// return xmlHttp;
//}
function userExists(CarNum) {
if (CarNum != "") {
//请求字符串
var url = "TC_Maintenance.aspx?CarNum=" + CarNum + '&_dc=' + new Date().getTime();
// 1. 创建XMLHttpRequest组件
xhr = createXMLHttpRequest();
// 2. 设置回调函数
xhr.onreadystatechange = readyDo;
// 3. 初始化XMLHttpRequest组件
xhr.open("GET", url, true);
// 4. 发送请求
xhr.send(null);
}
}
function readyDo() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
var b = xhr.responseText;
if (b == "true") {
document.getElementById("mess_double").style.display = "inline";
}
else {
document.getElementById("mess_double").style.display = "none";
}
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server" defaultbutton="btnAdd">
<asp:ScriptManager ID="smDetail" runat="server" EnablePartialRendering="true">
</asp:ScriptManager>
<div class="maincontent">
<asp:UpdatePanel ID="uplDetail" runat="server">
<ContentTemplate>
<div class="panel">
<div class="title">明细</div>
<div class="content">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="smartGrid2">
<tr>
<th width="13%" align="left">车牌号:</th>
<td width="37%">
<asp:TextBox ID="txtCarNum" runat="server" MaxLength="15" onblur="userExists(this.value) "/>
<asp:RequiredFieldValidator runat="server" ID="CarNum_Null_Check" ControlToValidate="txtCarNum" ErrorMessage="“车牌号”不能为空" Display="None" Height="5px" Width="5px" />
<span class="RequiredWarningStyle" runat="server" id="spCarNum">*</span>
<span id="mess_double" style="display: none; color: Red">该车牌号已存在,请重新输入</span>
</td>
</tr>
<br> var xhr;<br> //function createXMLHttpRequest1() {<br> // alert(">>>");<br> //}<br> function createXMLHttpRequest() {<br> if (window.ActiveXObject) {//如果是IE浏览器<br> return new ActiveXObject("Microsoft.XMLHTTP");<br> }<br> else if (window.XMLHttpRequest) {//非IE浏览器<br> return new XMLHttpRequest();<br> }<br> }<br> //function createXmlHttpRequest() {<br> // if (window.XMLHttpRequest) {<br> // xmlHttp = new XMLHttpRequest();</p> <pre><code> // if (xmlHttp.overrideMimeType) { // xmlHttp.overrideMimeType("text/xml"); // } // } // else if (window.ActiveXObject) { // try { // xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); // } // catch (e) { // xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); // } // } // if (!xmlHttp) { // window.alert("你的浏览器不支持创建XMLhttpRequest对象"); // } // return xmlHttp; //} function userExists(CarNum) { if (CarNum != "") { //请求字符串 var url = "TC_Maintenance.aspx?CarNum=" + CarNum + '&_dc=' + new Date().getTime(); // 1. 创建XMLHttpRequest组件 xhr = createXMLHttpRequest(); // 2. 设置回调函数 xhr.onreadystatechange = readyDo; // 3. 初始化XMLHttpRequest组件 xhr.open("GET", url, true); // 4. 发送请求 xhr.send(null); } } function readyDo() { if (xhr.readyState == 4) { if (xhr.status == 200) { var b = xhr.responseText; if (b == "true") { document.getElementById("mess_double").style.display = "inline"; } else { document.getElementById("mess_double").style.display = "none"; } } } } </script> </code></pre> <p></head><br> <body><br> <form id="form1" runat="server" defaultbutton="btnAdd"><br> <asp:ScriptManager ID="smDetail" runat="server" EnablePartialRendering="true"><br> <a href="/asp:ScriptManager">/asp:ScriptManager</a><br> <div class="maincontent"><br> <asp:UpdatePanel ID="uplDetail" runat="server"><br> <ContentTemplate><br> <div class="panel"><br> <div class="title">明细</div><br> <div class="content"><br> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="smartGrid2"><br> <tr><br> <th width="13%" align="left">车牌号:</th><br> <td width="37%"><br> <asp:TextBox ID="txtCarNum" runat="server" MaxLength="15" onblur="userExists(this.value) "/><br> <asp:RequiredFieldValidator runat="server" ID="CarNum_Null_Check" ControlToValidate="txtCarNum" ErrorMessage="“车牌号”不能为空" Display="None" Height="5px" Width="5px" /><br> <span class="RequiredWarningStyle" runat="server" id="spCarNum">*</span><br> <span id="mess_double" style="display: none; color: Red">该车牌号已存在,请重新输入</span><br> </td></p> <pre><code> </tr> </code></pre> <pre><code> </code></pre>