标签:
一、前台方法
function checkForm() {
checkState = true;
$(":text").each(function(i, val) {
if ($(this).is(":hidden")) {
return true;
}
if ($(this).hasClass("btx")) {
if (this.value == ‘‘) {
prevMsg = $(this).closest("td").prev().text().replace(":", "");
alert("请填写" + prevMsg.replace(/(^\s*)|(\s*$)/g, "") + "!");
try { this.focus(); } catch (pageerror) { }
checkState = false;
return checkState;
}
}
});
var L = document.getElementById("txtJZBH").value;
var m = document.getElementById("txtQYDM").value;
$.ajaxSetup({
async: false
});
if (L != "" ) {
$.get("GetData.ashx?jzbh=" + L +"&qyid=" +m +"", function(data) {
if (data != "no") {
alert( "已经存在机组编号为" + L + "的企业,请不要重复提交");
checkState = false;
return checkState;
}
});
}
return checkState;
}
二、后台
using System;
using System.Web;
using Huamai.ZL.Model;
using Huamai.ZL.BLL;
public class GetData : IHttpHandler {
private int jzbh;
private int qyid;
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
if (!string.IsNullOrEmpty(context.Request.QueryString["jzbh"]))
{
jzbh = int.Parse(context.Request.QueryString["jzbh"]);
}
if (!string.IsNullOrEmpty(context.Request.QueryString["qyid"]))
{
qyid = int.Parse(context.Request.QueryString["qyid"]);
}
ZL_QKJ_S_DLHY_SXBInfo info = ZL_QKJ_S_DLHY_SXBBLL.GetModelByQuery(" where JZBH=‘"+jzbh+"‘ and QYID !=‘"+qyid+"‘");
if (info != null)
{
System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();
string json = jss.Serialize(info);
context.Response.Write(json);
}
else
{
context.Response.Write("no");
}
}
public bool IsReusable {
get {
return false;
}
}
}
标签:
原文地址:http://www.cnblogs.com/supersh/p/4545482.html