Email Validation Code For Begineers

Sabarimahesh
Posted by Sabarimahesh under JavaScript category on | Points: 40 | Views : 1264
Try this
<script type='text/javascript'>
function emailValidator(id, Msg){
var exp= /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
if(id.value.match(exp)){
return true;
}else{
alert(Msg);
elem.focus();
return false;
}
}
</script>

<form>
Email: <input type='text' id='mailer'/>
<input type='button'
onclick="emailValidator1(document.getElementById('mailer'),'Invalid MailID')"
value='Chk_field' />
</form>

Comments or Responses

Posted by: Samarmir on: 4/4/2012 Level:Starter | Status: [Member] | Points: 10
Thanks for the code, but can the same code be applied to backend C# ?
Posted by: Sabarimahesh on: 4/4/2012 Level:Bronze | Status: [Member] | Points: 10
Samarmir
Sorry
Can't get it,

Plz ask clearly
Posted by: Sabarimahesh on: 4/4/2012 Level:Bronze | Status: [Member] | Points: 10
Samarmir
Sorry
Can't get it,

Plz ask clearly
Posted by: Sakthi.Singaravel on: 4/4/2012 Level:Silver | Status: [Member] | Points: 10
Hi,

can u post this code in vb .net
Posted by: Sabarimahesh on: 4/5/2012 Level:Bronze | Status: [Member] | Points: 10
Sakthi.Singaravel
If Txt_EmailId.Text <> "" Then

Dim Valid As Match = Regex.Match(Trim(Txt_EmailId.Text), "^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,3})$", RegexOptions.IgnoreCase)
If Valid.Success = False Then
MessageBox.Show("Invalid Emailaddress", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
Txt_EmailId.Focus()
Exit Function
End If
End If


Posted by: Sakthi.Singaravel on: 4/5/2012 Level:Silver | Status: [Member] | Points: 10
@ Sabari Mahesh P M

Thank you
Posted by: Sabarimahesh on: 4/9/2012 Level:Bronze | Status: [Member] | Points: 10
Sakthi.Singaravel

U R Welcome

Login to post response