午夜视频在线网站,日韩视频精品在线,中文字幕精品一区二区三区在线,在线播放精品,1024你懂我懂的旧版人,欧美日韩一级黄色片,一区二区三区在线观看视频

分享

js驗證文本框只能輸入手機(jī)號和電話號

 悟靜 2012-02-01
<script type="text/javascript">
        function yanzheng()
        {
            var a=document.getElementById("TextBox2");
            if(a.value=="")
            {
                alert('請輸入貨物名稱!');
                a.focus();
               return false;
            }
            var c=document.getElementById("Jsm2tbShowButton");
            if(c.value=="請選擇 ?。校h")
            {
                alert('請選擇出發(fā)地!');
                c.focus();
                return false;
            }
            var d=document.getElementById("TextBox4");
            var d1=document.getElementById("TextBox5");
            if((d.value=="")&&(d1.value==""))
            {
                alert('請完善貨量信息!');
                d.focus();
                return false;
            }
            if(d.value!="")
            {
                var ff=d.value;
                for(var i=0;i<ff.length;i++)
                {
                    if(ff.charAt(i)<'0'||ff.charAt(i)>'9')
                    {
                        alert('貨物重量只能輸入數(shù)字!');
                        d.focus();
                        return false;
                    }
                }
            }
            var f=document.getElementById("TextBox6");
            if(f.value=="")
            {
                alert('請輸入貨物數(shù)量!');
                f.focus();
                return false;
            }
             var d=document.getElementById("Jsm21tbShowButton");
            if(d.value=="請選擇 省-市-縣")
            {
                alert('請選擇目的地!');
                d.focus();
                return false;
            }
            var flag = "";
            var radioList=document.getElementById("CheckBoxList1");
            var inarr = radioList.getElementsByTagName('input');
            for (var i=0; i<inarr.length; i++)
            {
                if(inarr[i].type=="checkbox")
                 {
                    if(inarr[i].checked==true)   
                     {
                         flag = "ccc";
                     }
                  }
             }
             if(flag=="")
             {
                alert('請選擇貨運形式!');
                return false;
             }
             var e=document.getElementById("texttime");
            if(e.value=="")
            {
                alert('請選擇截止日期!');
                e.focus();
                return false;
            }
            else
            {
                var nowdate = new Date();
                var mon=nowdate.getMonth();
                var months=mon+1;
                if(CompareDate2(nowdate.getFullYear(),months,nowdate.getDate(),e.value))
                {
                    alert('截止時間需大于等于當(dāng)前日期!');
                    e.focus();
                    return false;
                }
            }
            var g=document.getElementById("TextBox7");
            if(g.value=="")
            {
                alert('請輸入聯(lián)系人!');
                g.focus();
                return false;
            }
            var h=document.getElementById("TextBox8");
            if(h.value=="")
            {
                alert('請輸入聯(lián)系電話!');
                h.focus();
                return false;
            }
            else
            {
                var reg = /^(\d{3,4})-(\d{7,8})/;//驗證電話號碼
                var regph=/[1][3-9][0-9]{9,9}/;//驗證手機(jī)號碼
                if(h.value.constructor===String)
                {
                    var re=h.value.match(reg);
                    var reph=h.value.match(regph);
                    if(re==null&&reph==null)//只能輸入正確格式的手機(jī)或電話號碼
                    {
                        alert('聯(lián)系方式格式有誤!');
                        h.focus();
                        return false;
                    }
                }
            }
            return true;
        }
        function CompareDate2(ny,nm,nd,n2)
        {
            var panduan=false;
            var t1=new Date(ny+'/'+nm+'/'+nd);
            var arr2=n2.split('-');
            var t2=new Date(arr2[0]+'/'+arr2[1]+'/'+arr2[2]);
            if(t1>t2)
            {
                panduan=true;
            }
            return panduan;
        }
    </script>

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多