email check using javascript

Posted by Klbaiju under JavaScript on 4/4/2012 | Points: 10 | Views : 1280 | Status : [Member] | Replies : 4
function validate2() {
var emailPat = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
var emailid=$("#txtccto").val();
var matchArray = emailid.match(emailPat);
if (matchArray == null)
{
alert("Your email address seems incorrect. Please try again.");
$("#txtccto").focus();
return false;
}
return true;

}
</script>
hi email validation has some problem

if i write h@hh.com
it is not working
if it is hh@hh.com working
how to correct this

Regards
baiju




Responses

Posted by: Sabarimahesh on: 4/4/2012 [Member] Bronze | Points: 25

Up
0
Down
<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>


Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Patel28rajendra on: 4/4/2012 [Member] Starter | Points: 25

Up
0
Down
Hi

try this

var filter=/^.+@.+\..{2,3}$/



R D Patel

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Klbaiju on: 4/4/2012 [Member] Starter | Points: 25

Up
0
Down
HI,
friend thanks a lot ur code working fine.

Regards
Baiju

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 4/5/2012 [Member] Bronze | Points: 25

Up
0
Down
Klbaiju


You are Welcome


Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response