The example of this article describes the method of JS authentication email address format. Share to everyone for your reference, specific as follows:
Example 1:
Copy Code code as follows:
<asp:textbox id= "Txt_email" runat= "Server" onblur= "Checkrate" (this.id) ></asp:TextBox>
function checkrate (input)
{
var re =/^[_ ". 0-9a-z-]+@ ([0-9a-z][0-9a-z-]+.) {1,4} [A-z] {2,3}$/i;
var nubmer = document.getElementById (input). value;
if (!re.test (Nubmer))
{
alert ("Please enter the correct format of the mailing Address");
document.getElementById (input). Value = "";
return false;
}
}
Example 2:
<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 ("Please enter your email address!! ");
return false;
else {
alert ("Hello, you entered incorrectly, please re-enter;");
document.getElementById ("TextBox1"). Value = "";
return false;
}
}
</script>
Copy Code code as follows:
<asp:textbox id= "TextBox1" runat= "Server" ></asp:TextBox>
<asp:button id= "Button3" runat= "Server" text= "button" onclientclick= "Return Isvalidmail ()" onclick= "Button3_Click "/>
I hope this article will help you with JavaScript programming.