Skip to content

Instantly share code, notes, and snippets.

@jayproulx
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jayproulx/62bbd62cc23675d9918f to your computer and use it in GitHub Desktop.
Save jayproulx/62bbd62cc23675d9918f to your computer and use it in GitHub Desktop.
Air Canada Email Validation
// http://help-aircanada.com/aircanada-help/js/aircanada_11112013.js
//This function is used to validate email address : Returns true if email is valid
function isEmailValid(emailToValidate){
//var regex1=/^([_A-Za-z0-9-/&]+(\.[_A-Za-z0-9-/&]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*\.(([A-Za-z]{2,3})|(aero|coop|info|museum)))?$/
//return regex1.test(emailToValidate);
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,17})+$/.test(emailToValidate))
{
return (true);
}
alert(document.getElementById('invalidemail').value);
//.alert("Please Enter A Valid EmailAddress as (abc@xyz.com)");
return (false) ;
}
@jayproulx
Copy link
Author

Looks like the longest TLD is 17 characters http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment