I’ve been trying out validate.js and I’ve got it set up and validating but I can’t seem to figure out how to let the form post to the database once its validated. The database is all set up and everything (using Postgres) but validate.js interferes and doesn’t let the form post.
<script>
new FormValidator('contact', [{
name: 'name',
rules: 'required'
}, {
name: 'email',
rules: 'required|valid_email'
}, {
name: 'message',
rules: 'required'
}, {
name: 'minlength',
display: 'min length',
rules: 'min_length[8]'
}], function(errors, event) {
var SELECTOR_ERRORS = $('.error_box'),
SELECTOR_SUCCESS = $('.success_box');
if (errors.length > 0) {
SELECTOR_ERRORS.empty();
for (var i = 0, errorLength = errors.length; i < errorLength; i++) {
SELECTOR_ERRORS.append(errors[i].message + '<br />');
}
SELECTOR_SUCCESS.css({ display: 'none' });
SELECTOR_ERRORS.fadeIn(200);
} else {
SELECTOR_ERRORS.css({ display: 'none' });
SELECTOR_SUCCESS.fadeIn(200);
}
if (event && event.preventDefault) {
event.preventDefault();
} else if (event) {
event.returnValue = false;
}
});
</script>
This is what I’ve got for my validation script but at the moment, all that happens when the form is validated is display: none is removed from the div called success_box.
So basically, I’m asking how I might go about posting the form data once the form is completed successfully. I can post my form if anyone requires it but it’s already working if you remove validate.js so I don’t see the need at the moment.
Thanks!
Oops, sorry guys. If anyone else has this issue in the future, the form doesn’t submit because of the following line:
Get rid of that and you should be fine.
Sorry about that.