Skip to content

Instantly share code, notes, and snippets.

@quyen91
Created April 14, 2016 14:05
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 quyen91/9f6ccaa4871145633757adb06cf031d2 to your computer and use it in GitHub Desktop.
Save quyen91/9f6ccaa4871145633757adb06cf031d2 to your computer and use it in GitHub Desktop.
$('#myModal').on('submit', function(e) {
var rex = /^[\w-]+(\.[\w-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)*?\.[a-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?$/
var email = $('#email');
if(!email.val()){
$('#error-show').html("<small>* Email required</small>");
e.preventDefault();
}else{
if(!rex.test(email.val())){
$('#error-show').html("<small>* Invalid email</small>");
e.preventDefault();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment