hi all
I am doing a form where i have to validate the email, all of the other control is working just the way it is supposed to work but I have been trying to validate the email for the longest while and it is not working properly or better yet it is not validating, I dont know if it is the codes that I am using or if there is an error there that I am not seeing, can someone help me out and let me know if there is an error here is the codes that I am using.
function ValidateForm()
{
var a, i, error, check, title, firstname, lastname, address;
var txtemail, gender, userName, pword, cword;
a=0;
error=false;
check=false;
title=document.getElementById("title").value;
firstname=document.getElementById("firstname").value;
lastname=document.getElementById("lastname").value;
address=document.getElementById("address").value;
if(title=="" || title==null)
{
alert("Please select a title");
error=true;
return false;
}
if(firstname=="" || firstname==null)
{
alert("Please enter your first name");
error=true;
return false;
}
if(lastname=="" || lastname==null)
{
alert("Please enter your last name");
error=true;
return false;
}
if(address=="" || address==null)
{
alert("Please enter your address");
error=true;
return false;
}
}
function IsValidEmail(txtemail)
{
var emailregex = new regex(/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/);
var valid = emailregex.test(txtemail);
}
function ValidateEmail()
{
var txtemail = document.getElementById("txtemail").value;
if(IsValidEmail(txtemail))
{
alert("Invalid email address");
}
else
{
alert("valid email address");
}
}