表单提交判断,数据只能提交一次判断

<! DOCTYPE html >
< html  lang ="en" >

< head >
     < meta  charset ="UTF-8" >
     < title >物业报修-填写信息 </ title >
     < meta  content ="yes"  name ="apple-mobile-web-app-capable" >
     < meta  content ="yes"  name ="apple-touch-fullscreen" >
     < meta  content ="telephone=no"  name ="format-detection" >
     < meta  content ="black"  name ="apple-mobile-web-app-status-bar-style" >
     < meta  name ="viewport"  content ="width=device-width,minimum-scale=1.0,maximum-scale=1.0"   />
     < link  rel ="stylesheet"  type ="text/css"  href ="http://static.17shihui.com/pageapp/css/comact/mobile.common.css?static_version=1438944758593" >
     < link  rel ="stylesheet"  type ="text/css"  href ="http://static.17shihui.com/communitym/cm1.10/css/mobile.alert.css" >
     < link  rel ="stylesheet"  type ="text/css"  href ="../css/style.css" >
</ head >

< body >
     < div  class ="fill_wrap" >
         < label  class ="name ipt" >
             < input  type ="text"  placeholder ="请输入您的姓名"  id ="name" >
             < class ="name_in" ></ p >
         </ label >
         < label  class ="tel ipt" >
             < input  type ="tel"  placeholder ="请输入您的电话"  id ="tel" >
             < class ="tel_in" ></ p >
         </ label >
         < textarea  class ="int_des"  id ="description"  placeholder ="请将情况描述的尽量清晰,包括具体位置,损坏物品等。" ></ textarea >
         < class ="des_in" ></ p >
         < href ="javascript:void(0)"  class ="btns"  id ="btns" >反馈 </ a >
     </ div >
     < script  src ="http://static.17shihui.cn/libs/zepto/zepto.min.js" ></ script >
     < script  src ="http://static.17shihui.com/communitym/cm1.10/js/mobile.alert.js" ></ script >
     < script  type ="text/javascript" >
     function getQueryString(name) {
     var reg =  new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
     var r = window.location.search.substr(1).match(reg);
     if (r !=  nullreturn r[2];
     return  null;
};

function fillCome(ele) {

     var name = $("#name").val();
     var tel = $("#tel").val();
     var description = $("#description").val();
     var app_id = getQueryString('app_id');
     var gid = getQueryString('gid')
     if (!fillTab()) {
         return;
    }
    ele.addClass("box");
    $.ajax({
        type: 'POST',
        url: '/saasapi/main/saas/repair/add',
        data: { name: name, tel: tel, description: description, app_id: app_id, gid: gid },
        dataType: 'json',
        headers: { Authorization: getQueryString('mauth').replace("+", " ") },
        success:  function(data) {
             if (data.apistatus == 1) {
                alert("感谢您的帮助和反馈,物业会尽快处理");
            }

            ele.removeClass("box");
        }
    })
}

function fillShow() {
    $.ajax({
        type: 'GET',
        url: '/saasapi/main/saas/repair/get_by_id',
        data: { id: getQueryString('id') },
        dataType: 'json',
        headers: { mauth: getQueryString('mauth').replace("+", " ") },
        success:  function(data) {
             var rel = data.result;
             if (data.apistatus == 1) {
                $(".ipt input").hide();
                $(".int_des").hide();
                $("#btns").hide();
                $(".name_in").show().html(rel.name);
                $(".tel_in").show().html(rel.tel);
                $(".des_in").show().html(rel.description);
            }

        }
    })

}

if (getQueryString("id")) {
    fillShow();
else {
    $("#btns").click( function() {
         var _this = $( this);
         if (!_this.hasClass("box")) {
            fillCome(_this);
        }
    })
}

function fillTab() {
     var name = $("#name").val();
     var tel = $("#tel").val();
     var description = $("#description").val();

     var str2 = /^[\u4e00-\u9fa5A-Za-z]{2,8}$/;
     var str3 = /^1[0-9]{10}$/;

     if (name == "") {
        alert("请输入您的姓名");
         return  false;
    }
     if (!str2.test(name)) {
        alert("姓名格式不对");
         return  false;
    }
     if (tel == "") {
        alert("请输入您的电话");
         return  false;
    }
     if (!str3.test(tel)) {
        alert("手机格式不对");
         return  false;
    }
     if (description == "") {
        alert("问题描述不能为空");
         return  false;
    }
     return  true;
}

     </ script >
</ body >

</ html >

 

转载于:https://www.cnblogs.com/xiaoleidiv/p/5568033.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值