Skip to content

Instantly share code, notes, and snippets.

@Crocmagnon
Last active August 14, 2018 08:24
Show Gist options
  • Select an option

  • Save Crocmagnon/ee68c2c18c2c3b7a85730b319743c354 to your computer and use it in GitHub Desktop.

Select an option

Save Crocmagnon/ee68c2c18c2c3b7a85730b319743c354 to your computer and use it in GitHub Desktop.
Crappy email check. Don't do this at home !
var regexEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if(email == '' || !regexEmail.test(email)){
$('.edit_data input[name="customer[email]').after("<p class='form-error'>Merci de renseigner un email correct</p>");
return false;
}
@Crocmagnon
Copy link
Author

You'll quickly notice that only 2-3 characters TLD work. All with 4 characters and up will throw the error.

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