I am trying to validate my form on submit and if the input's are all filled in they submit to register.php
My problem being it only works if all inputs are blank - otherwise it errors - I'm just trying to check if any of those fields are blank before submiting
function submitform() {
if ($('#name, #email, #user, #address, #phone').val().length === 0) {
$(this).addClass('warning');
} else {
alert("form submitted");
}
}
==instead of===at line 2 ?if(($('#name').val() > 0) && ($('#user').val() > 0) ....) alert('submitted') else alert('blank!')BETTER WAY = Jorge's answer