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
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.