menu

Thursday, July 1, 2010

Email id validation through JavaScript (Using Expression)

Write this javascript code inside "HEAD" - "SCRIPT" tag

function checkEmail(myForm)
{
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.TextBox1.value))
{
return (true)
}
else
{
alert("Enter valid Email id please.")
TextBox1.focus()
return (false)
}
}

call this function in form's onsubmit event

form id="myForm" runat="server" onsubmit="return checkEmail(this)"

1 comment:

  1. It is very nice post.It is good post. It is simple and best. It helpful for future use.You can test your knowledge in html by attending HTML Quiz .

    ReplyDelete