正則表達式驗證

1.驗證聯繫電話:/^[0-9]{1}[0-9]{2,3}-[1-9]{1}[0-9]{5,8}$/

2.驗證手機號碼:/^1[3|4|5|8][0-9]\d{4,8}$/

3.驗證郵箱地址:/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/

4.驗證有多少個字,按字節算

           var l=0;
           for(var i=0;i<education.length;i++)
           {
               if(education.charCodeAt(i)>255) l+=2;
               else l++;
           }
           if(l>300){
               alert('教育經歷不能超過150個漢字!');
               $('#education').focus();
               return false;
           }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章