Skip to content

Instantly share code, notes, and snippets.

@mcavaliere
Created December 21, 2015 21:11
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 mcavaliere/c465ce781c9c5a9b8755 to your computer and use it in GitHub Desktop.
Save mcavaliere/c465ce781c9c5a9b8755 to your computer and use it in GitHub Desktop.
var LoginFom = {
element: $("form#login-form"),
hasErrors: function() {
// validation code here...
// returns true or false.
}
};
// ...
var ErrorContainer = {
element: $("div.form-errors")
};
if (LoginForm.hasErrors()) {
ErrorContainer.element.show();
}
LoginForm.element.addClass("has-errors");
$("input.submit").on("click", function() {
ErrorContainer.element.remove();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment