Topic: Help

hi all..
i m newbie...so pls be patient with me...
actually i need to do validation for my email field in my form.
i did validation for the empty field sucessfully.
but i want to check whether the email field contains @ symbol or not...
if the field doesn't contain @ symbol alert message has to be displayed..for this wat can i do?
pls help me....Thankx in advance........

my code starts here.................................

<html>
<head>
<title>Rethy</title>
<script type="text/javascript">

function validate()
{
if(""==document.frm.txt.value)
{
alert("Enter");
document.frm.txt.focus();

return false;
}

}
</script>

</head>
<body>
<form name="frm" method="post">
Email: <input type="text" name="txt"><p>
<input type="button" value="SUBMIT" onclick="return validate();">
</form>
</body>
</html>

Re: Help

   var email_address = "me@me.com";

   var email_requirements = /^[^@]+@[^@.]+\.[^@]*\w\w$/  ;

   if (!email_requirements.test(email_address)) {
      alert("Please enter a valid email address!");
   }
   else
   {
      alert("yee haw! y'er a valid one!");
   }


-patrick

Last edited by patrick99e99 (2008-09-01 22:36:44)