Created
September 16, 2013 08:51
-
-
Save frayhan32/6578157 to your computer and use it in GitHub Desktop.
Email Validation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//********************************// | |
//********Email Validation********// | |
//********************************// | |
//***************************************************// | |
//********Plese read instruction before using********// | |
//***************************************************// | |
//*This is simple email validation function accept one arguments using regular expression*// | |
//*if you havent understand about regular expression you can visit w3school or googling*// | |
//*Useful when deal with form integratin particulary when filling email requirement*// | |
//*i related to trim function so e.g when focusout the val of email no cointains space*// | |
//*if you havent see my trim function refere this link *// | |
//*https://gist.github.com/frayhan32/6568660*// | |
function validEmail(eMail){ | |
if(/^.+@\w+\.(?:\w{3}|\w{2,3}\.\w{2})$/.test(trim(eMail))==true){ | |
//code when goes right | |
return true; | |
}else{ | |
//or false | |
return false; | |
} | |
} | |
//*Test him*// | |
console.log(validEmail('frayhan32@gmail.com')); //output true | |
console.log(validEmail('frayhan32@yahoo.co.id')); //output true | |
console.log(validEmail('frayhan32@net.id')); //output true | |
console.log(validEmail('frayhan32@ne')); //output false | |
console.log(validEmail('frayhan32@net.ido')); //output false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment