Reputation: 356
I am attempting to create a registration form that uses jquery for validation. When i click submit it doesnt seem to be working, it just lets me add anything into my Database even if there are missing fields or the passwords arent matching.
I have created a fiddle any help would be greatly appreciated.
if(username == "") {
$("span.val_username").html("This field is required".).addClass('validate');
validation_holder = 1;
} else {
$("span.val_username").html("");
}
if(name == "") {
$("span.val_name").html("This field is required".).addClass('validate');
validation_holder = 1;
} else {
$("span.val_name").html("");
}
Thank you
Upvotes: 0
Views: 45
Reputation: 1203
Firstly it seems that your form is submitting because you haven't overriden the onsubmit event so basically you need to put in the form opening tag:
onsubmit="return false;"
this will prevent the form from submitting automatically.. now you need to fix the validation method..
I fixed most of the bugs here.. you need to look at the validation process itself.
Upvotes: 1