Validate email Javascript

ตรวจสอบความถูกต้องของ email ครับ

Code:Header

<script language="Javascript">

function validatefrm(){ 

 var theForm = document.form1;

 var emailRE = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;

 var errMsg = "";

 var setfocus = ""; 	if (theForm['textfield'].value != ""){

if (!emailRE.test(theForm['mail'].value)){

 		errMsg = "mail Fail!";

 		setfocus = "['mail']";

 	}

 }

 if (errMsg != ""){

 	alert(errMsg);

 	eval("theForm" + setfocus + ".focus()");

 }

 else theForm.submit();

}

</script>

Code:Body

<form action="" method="post" name="form1" onSubmit="validatefrm();return false;">

   <input type="text" name="mail">

   <input type="submit" name="Submit" value="Submit">

 </form>
You can leave a response, or trackback from your own site. Responses are currently closed, but you can trackback from your own site. You can skip to the end and leave a response. Pinging is currently not allowed. Both comments and pings are currently closed.
Powered by WordPress | Shop Free T-Mobile Phones Online | Thanks to Verizon Phones without Contract, MMORPG Games and Sell Car