Skip to content

Instantly share code, notes, and snippets.

@stympy
Created November 30, 2008 04:57
Show Gist options
  • Save stympy/30387 to your computer and use it in GitHub Desktop.
Save stympy/30387 to your computer and use it in GitHub Desktop.
(function($) {
$.extend($.fn, {
validate: function(options) {
var form = this;
this.submit(function(event) {
form.find('label.error').filter('[generated=true]').empty()
if ((req_fields = form.find('.required[value=""]')).length > 0) {
req_fields.after('<label class="error" generated="true">This field is required</label>')
req_fields[0].focus()
return false;
} else {
return true
}
})
}
})
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment