<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 27,  comments - 14,  trackbacks - 0
      1 //================================================= 
      2 // 
      3 //    驗證功能的    javascript 
      4 // 
      5 //   最后修改日期: 2005/02/28 
      6 // 
      7 //================================================= 
      8  
      9 ////////////////////////////////////////////////////// 
     10 // 判斷是否閏年  
     11 // 參數 intYear 代表年份的值  
     12 // return   true: 是閏年    
     13 //         false: 不是閏年  
     14 // 
     15 function LeapYear(intYear)  
     16 
     17     if (intYear % 100 == 0
     18     { 
     19         if (intYear % 400 == 0) { return true; } 
     20     }  
     21     else 
     22     {  
     23       if ((intYear % 4== 0) { return true; }  
     24     }  
     25     return false;  
     26 }  
     27  
     28 ////////////////////////////////////////////////////// 
     29 // 驗證日期 
     30 //  
     31 function checkdate(TextID)  
     32 
     33     var flag = true
     34     var searchStr = /^[0-9]{4}-(0[1-9]|[1-9]|1[0-2])-((0[1-9]|[1-9])|1[0-9]|2[0-9]|3[0-1])$/ 
     35      
     36     if!searchStr.test(TextID.value) ) 
     37     { 
     38         if(""==TextID.value) 
     39         {} 
     40         else 
     41         { 
     42             TextID.value = ""
     43             alert("您輸入的日期格式錯誤!"); 
     44         } 
     45     } 
     46     else  
     47     {  
     48         var getdate = TextID.value; 
     49          
     50         // 獲得年  
     51         var year=getdate.substr(0,getdate.indexOf('-')); 
     52         // 下面操作獲得月份 
     53         var transition_month=getdate.substr(0,getdate.lastIndexOf('-')); 
     54         var month=transition_month.substr(transition_month.lastIndexOf('-')+1,transition_month.length); 
     55         // 下面操作獲得日期  
     56         var day=getdate.substr(getdate.lastIndexOf('-')+1,getdate.length); 
     57          
     58         if (month.indexOf('0')==0)  
     59         {  
     60             month=month.substr(1,month.length); 
     61         } 
     62         if (day.indexOf('0')==0)  
     63         {  
     64             day=day.substr(1,day.length); 
     65         } 
     66          
     67         // 判斷2月份  
     68         if( month==2 ) 
     69         { 
     70             if (LeapYear(year))  
     71             { 
     72                 if (day>29 || day<1
     73                     flag=false
     74             } 
     75             else 
     76             { 
     77                 if (day>28 || day<1
     78                     flag=false
     79             } 
     80         } 
     81         // 4,6,9,11月份日期不能超過30  
     82         if( (month==4 || month==6 || month==9 || month==11&& (day>30) ) 
     83         { 
     84             flag=false
     85         } 
     86     } 
     87  
     88     if ( flag==false )  
     89     {  
     90         TextID.value = ""
     91         alert("您輸入的日期不合法!");  
     92     } 
     93 
     94  
     95 ///////////////////////////////////////////////// 
     96 // 驗證時間 
     97 //  
     98 function checktime(TextID)  
     99 {  
    100     var flag = true
    101     var searchStr = /^[0-9]{4}-(0[1-9]|[1-9]|1[1-2])-((0[1-9]|[1-9])|1[0-9]|2[0-9]|3[0-1]) ((0[1-9]|[1-9])|1[0-9]|2[0-4]):((0[1-9]|[1-9])|[1-5][0-9]):((0[1-9]|[1-9])|[1-5][0-9])$/ 
    102     if!searchStr.test(TextID.value) ) 
    103     { 
    104         if(""==TextID.value) 
    105         {} 
    106         else 
    107         { 
    108             TextID.value = ""
    109             alert("您輸入的日期時間格式錯誤!"); 
    110          } 
    111     } 
    112     else  
    113     {  
    114         var getdate = TextID.value; 
    115          
    116         // 獲得年  
    117         var year=getdate.substr(0,getdate.indexOf('-')); 
    118         // 下面操作獲得月份 
    119         var transition_month=getdate.substr(0,getdate.lastIndexOf('-')); 
    120         var month=transition_month.substr(transition_month.lastIndexOf('-')+1,transition_month.length); 
    121         // 下面操作獲得日期  
    122         var day=getdate.substr(getdate.lastIndexOf('-')+1,getdate.length); 
    123          
    124         if (month.indexOf('0')==0)  
    125         {  
    126             month=month.substr(1,month.length); 
    127         } 
    128         if (day.indexOf('0')==0)  
    129         {  
    130             day=day.substr(1,day.length); 
    131         } 
    132          
    133         // 判斷2月份  
    134         if( month==2 ) 
    135         { 
    136             if (LeapYear(year))  
    137             { 
    138                 if (day>29 || day<1
    139                     flag=false
    140             } 
    141             else 
    142             { 
    143                 if (day>28 || day<1
    144                     flag=false
    145             } 
    146         } 
    147         // 4,6,9,11月份日期不能超過30  
    148         if( (month==4 || month==6 || month==9 || month==11&& (day>30) ) 
    149         { 
    150             flag=false
    151         } 
    152     } 
    153  
    154     if ( flag==false )  
    155     {  
    156         TextID.value = ""
    157         alert("您輸入的日期不合法!");  
    158     } 
    159 }  
    160  
    161 ///////////////////////////////////////////////// 
    162 // 數字輸入控制 
    163 // 
    164 function NumCheck(obj) 
    165 
    166     if(obj.value==""
    167     { 
    168     } 
    169     else 
    170     { 
    171         if (!isNumeric(obj.value)) 
    172         { 
    173             alert("請輸入整數!"); 
    174             obj.focus(); 
    175             obj.value = ""
    176             return (false); 
    177         } 
    178         else 
    179         {     
    180         } 
    181     }     
    182 
    183  
    184 ///////////////////////////////////////////////// 
    185 // 判斷是否是數字的函數 
    186 // 
    187 function isNumeric(strNumber) 
    188 {  
    189     //return (strNumber.search(/^(-|\+)?\d+(\.\d+)?$/) != -1);  
    190     return (strNumber.search(/^(\d+)?$/!= -1);  
    191 }  
    192  
    193 ///////////////////////////////////////////////// 
    194 // 驗證Email地址 
    195 // 
    196 function checkEmail(TextID) 
    197 
    198     var searchStr = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/ 
    199     if!searchStr.test(TextID.value) ) 
    200     { 
    201         if(""==TextID.value) 
    202         {} 
    203         else 
    204         { 
    205             TextID.value = ""
    206             alert("Email 地址格式錯誤!"); 
    207         } 
    208     } 
    209 
    210  
    211 ///////////////////////////////////////////////// 
    212 // 驗證電話號碼 
    213 // 
    214 function checkPhone(TextID) 
    215 
    216     var searchStr = /(^[0-9]{3,4}\-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/ 
    217     if!searchStr.test(TextID.value) ) 
    218     { 
    219         if(""==TextID.value) 
    220         {} 
    221         else 
    222         { 
    223             TextID.value = ""
    224             alert("電話號碼格式錯誤!"); 
    225         } 
    226     } 
    227 }  
    228  
    229 //-------------------------------------  The end   ----------------------------------------------- 
    posted on 2007-08-28 09:07 Scott.Pan 閱讀(335) 評論(0)  編輯  收藏 所屬分類: 代碼收藏夾
    <2007年8月>
    2930311234
    567891011
    12131415161718
    19202122232425
    2627282930311
    2345678

    常用鏈接

    留言簿(4)

    隨筆分類

    隨筆檔案

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 影音先锋在线免费观看| 女人体1963午夜免费视频| 欧美a级在线现免费观看| 亚洲AV午夜福利精品一区二区| 一级做性色a爰片久久毛片免费| 免费国产精品视频| 日韩免费在线中文字幕| 国产精品亚洲产品一区二区三区| 免费国产黄网站在线看| 91麻豆精品国产自产在线观看亚洲 | 91精品国产免费入口| 亚洲国产精品一区| 99久9在线|免费| 亚洲国产精品综合久久久| 国产成人免费爽爽爽视频| 亚洲精品无码永久在线观看男男 | 中文字幕在线日亚洲9| 日本v片免费一区二区三区| 特级毛片A级毛片免费播放| 精品国产人成亚洲区| 久久精品中文字幕免费| 亚洲成年人电影网站| 免费羞羞视频网站| 成人免费网站视频www| 亚洲国产三级在线观看| 国产精品视频免费| 朝桐光亚洲专区在线中文字幕| 日韩精品亚洲aⅴ在线影院| 国产成人精品无码免费看| 亚洲小说区图片区| 国产无遮挡色视频免费视频| 国产黄在线播放免费观看| 91久久亚洲国产成人精品性色| 好男人视频社区精品免费| 狠狠躁狠狠爱免费视频无码| 中文字幕亚洲色图| 日本高清免费aaaaa大片视频| 国产成人自产拍免费视频| 亚洲人成日本在线观看| 亚洲日韩国产一区二区三区| 精品国产污污免费网站aⅴ|