I've written the following function the check whether or not a required field is empty upon form submission:
I then check on submission like this:Code:$.fn.checkRequired = function(){ return this.each(function(){ if (this.val()==''){ $("<div class='error'>some error message</div>").insertAfter('this'); }; }); };
I'm not sure if I'm not calling the function correctly or if the function has problems (or both). Any ideas on how I might do this?Code:$('form').submit(function(){ return $('form.required').checkRequired(); });


Reply With Quote

Bookmarks