hi all,
am new in javascript.
i have used to develop one asp.net application.
here i have make it used one validation process using java script.
i need to validate my email address.
if my email address is valid, i have redirect to another page.
if my email address is not valid, am getting invalid mail id.
but my problem is,
if my email address is valid, i can't able to redirect to another page. please find the code below
and let me know where am made mistake or else give me a valid code.
my code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function validEmail()
{
var mail = document.getElementById('email').value; // where `mail` is id of your input form
var email = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
if (mail.match(email))
{
window.location="Default3.aspx";
}
else
{
alert("Invalid Email !!!");
return false;
}
return true;
}
</script>
</head>
<body>
<form id="form1" name="form1" action="" method="post" runat="server">
<div>
<input type="text" name="email" id="email">
<asp:Button ID="Button1" runat="server" OnClientClick="return validEmail()" Text="Button" OnClick="Button1_Click" />
</div>
</form>
</body>
</html>
thanks in advance