JS驗證電子郵件地址格式


<script type="text/javascript">        

function isValidMail() {            

  var TextVal = document.getElementById("TextBox1").value;            

  var Regex = /^(?:\w+\.?)*\w+@(?:\w+\.)*\w+$/;            

  if (Regex.test(TextVal)){                

  alert(true);            

  }            

  else {                

  if (TextVal == "") {                    

    alert("請輸入電子郵件地址!!");                    

  return false;                

  }                

  else {                    

  alert("您好,你輸入不正確,請重新輸入;");                    

     document.getElementById("TextBox1").value = "";                    

  return false;                

    }            

  }        

}    

</script>

 

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>    

<asp:Button ID="Button3" runat="server" Text="Button"  OnClientClick="return isValidMail()" OnClick="Button3_Click" />


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM