Skip to content

Instantly share code, notes, and snippets.

Created August 5, 2016 18:51
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 anonymous/ae5dfdbff7fbd9edb205d69b778f334c to your computer and use it in GitHub Desktop.
Save anonymous/ae5dfdbff7fbd9edb205d69b778f334c to your computer and use it in GitHub Desktop.
function validateLoginForm() {
$('#username').val($.trim($('#username').val()));
if ($('#username').val().search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1) {
$('#username').focus();
alert("Your username should be the email address you registered with.");
return false;
} else if ($('#password').val() == "") {
$('#password').focus();
alert("Password is required.");
return false;
} else if ($('#token').val() == "") {
return false;
} else {
$("#login-form button").attr('disabled', 'disabled');
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment