Skip to content

Instantly share code, notes, and snippets.

@rdallaire
Created June 25, 2019 22:22
Show Gist options
  • Save rdallaire/8e4de4f18291b716ec91a9ea6ae7f33b to your computer and use it in GitHub Desktop.
Save rdallaire/8e4de4f18291b716ec91a9ea6ae7f33b to your computer and use it in GitHub Desktop.
jquery email validation
$('#cases-email').keyup(function(){
var email = $('#cases-email').val();
var filter = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (!filter.test(email)) {
//alert('Please provide a valid email address');
$("#cases-error-email").text('Please enter a valid email.');
$('#support-contact-cases .button').attr('disabled', true);
email.focus();
//return false;
} else {
$('#cases-error-email').text('');
$('#support-contact-cases .button').attr('disabled', false);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment