幾個常用的js判斷方法 CheckForm

           

           1function isInt(intValue){
           2    var intPattern=/^0$|^[1-9]\d*$///整數(shù)的正則表達(dá)式
           3    result=intPattern.test(intValue);
           4    return result;
           5}

           6
           7function isFloat(floatValue){
           8    var floatPattern=/^0(\.\d+)?$|^[1-9]\d*(\.\d+)?$///小數(shù)的正則表達(dá)式
           9    result=floatPattern.test(floatValue);
          10    return result;
          11}

          12function isEmail(emailValue){
          13    var emailPattern=/^[^@.]+@([^@.]+\.)+[^@.]+$///郵箱的正則表達(dá)式
          14    result=emailPattern.test(emailValue);
          15    return result;
          16}

          17function isNum(obj,alt){
          18    var numPattern=/^\d*$///數(shù)字的正則表達(dá)式
          19    result=numPattern.test(obj.value);
          20    if(!result){
          21        alert(alt);
          22        obj.focus();
          23    }

          24    return result;
          25}

          26
          27function isChar(obj,alt){
          28    var charPattern=/^[a-zA-Z]*$///是否為字母
          29    result=charPattern.test(obj.value);
          30    if(!result){
          31        alert(alt);
          32        obj.focus();
          33    }

          34    return result;
          35}

          36
          37function isCharNum(flagValue){
          38    var flagPattern=/^[a-zA-Z0-9]*$///是否為字母和數(shù)字(傳真標(biāo)識符)
          39    result=flagPattern.test(flagValue);
          40    return result;
          41}

          42function isBlank(obj,alt){
          43    if(obj.value==""){
          44        alert(alt);
          45        obj.focus();
          46        return true;
          47    }

          48    return false;
          49}

          50


          posted on 2009-07-06 10:12 魯勝迪 閱讀(1291) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          <2009年7月>
          2829301234
          567891011
          12131415161718
          19202122232425
          2627282930311
          2345678

          導(dǎo)航

          統(tǒng)計

          常用鏈接

          留言簿(4)

          隨筆分類

          隨筆檔案

          文章分類

          新聞分類

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 新昌县| 新闻| 阿合奇县| 安泽县| 天峻县| 彩票| 海伦市| 临澧县| 攀枝花市| 邵东县| 璧山县| 安新县| 山西省| 鄂尔多斯市| 攀枝花市| 疏勒县| 固安县| 阿拉善右旗| 英山县| 盘山县| 林甸县| 曲麻莱县| 碌曲县| 分宜县| 灵台县| 资兴市| 稷山县| 萨迦县| 临安市| 巫溪县| 佳木斯市| 洱源县| 宿松县| 光山县| 盐池县| 天峻县| 汉阴县| 红桥区| 汽车| 汉中市| 灵川县|