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

一、前台方法

 

  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("txtSJJQTBH").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;
                      
                    }
                });
            }
         
            $(".fdx").each(function() {        //遍历class为fdx的文本框
            var re = /^[0-9]+.?[0-9]*$/;
            if (this.value != "" && !re.test(this.value)) {
                prevMsg = $(this).closest("td").prev().text().replace(":", "");
                alert( prevMsg.replace(/(^\s*)|(\s*$)/g, "") + "必须为数字!");
                try { this.focus(); } catch (pageerror) { }
                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;
        }
    }

}

posted @ 2015-06-02 09:11  嫣然美  阅读(217)  评论(0编辑  收藏  举报