How to validate a Email-address, in Form using JavaScript?

Questions by Devika.N   answers by Devika.N

Showing Answers 1 - 2 of 2 Answers

basetutor

  • May 10th, 2007
 


Simply cut and paste the below code into the <body> section of your page. It
contains a form with one box that is checked for "email validity". You can add in more form elements into the form, as you would with any other form.


<form name="validation" onSubmit="return checkbae()">
Please input a valid email address:<br>
<input type="text" size=18 name="emailcheck">
<input type="submit" value="Submit">
</form>
<script language="JavaScript1.2">


var testresults
function checkemail(){
var str=document.validation.emailcheck.value
var filter=/^([w-]+(?:.[w-]+)*)@((?:[w-]+.)*w[w-]{0,66}).([a-z]{2,6}(?:.[a-z]{2})?)$/i
if (filter.test(str))
testresults=true
else{
alert("Please input a valid email address!")
testresults=false
}
return (testresults)
}
</script>

<script>
function checkbae(){
if (document.layers||document.getElementById||document.all)
return checkemail()
else
return true
}
</script>


  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions