Thursday, April 12, 2012

jQuery form error checking

I'm doing a simple jQuery form checker for a website. I have two forms on the website: a login form and a signup form. My code is as followed:



$('.btn').click(function(e) {
e.preventDefault();
// DOES SOME ERROR CHECKING HERE
if { hasError $('div.error').fadeIn() }

else { $(this).parents('form').submit() }
});


So my question is, both the login button and the signup button has a class called btn, how can I have the them check their own form instead of checking all the forms on the page since $(this).parents('form') will get both the signup and login form?



Thank you!





No comments:

Post a Comment