jquery驗證手機號碼和郵箱地址例子

//jquery驗證郵箱 html

    function checkSubmitEmail(){ jquery

       if($("#email").val()==""){ htm

    $("#confirmMsg").html("郵箱地址不能爲空!"); it

    $("#email").focus(); io

    return false; function

   } email

   if(!$("#email").val().match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)){ query

    $("#confirmMsg").html("郵箱格式不正確!請從新輸入!"); mail

    $("#email").focus(); co

    return false; 

   } 

   return true; 

    } 

    

    //jquery驗證手機號碼 

    function checkSubmitMobil(){ 

       if($("#mobil").val()==""){ 

    $("#moileMsg").html("手機號碼不能爲空!"); 

    $("#mobil").focus(); 

    return false; 

   } 

 

   if(!$("#mobil").val().match(/^1[3|4|5|8][0-9]\d{4,8}$/)){ 

    $("#moileMsg").html("手機號碼格式不正確!請從新輸入!"); 

    $("#mobil").focus(); 

    return false; 

   } 

   return true; 

    }

相關文章
相關標籤/搜索