码迷,mamicode.com
首页 > 其他好文 > 详细

判断所填写的内容是否为空并不能重复

时间:2015-06-02 10:46:32      阅读:88      评论:0      收藏:0      [点我收藏+]

标签:

一、前台方法

 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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!