I am looking for a way that when a form is submitted it will check if the value entered in "spaces" > "spaces left". If it is show an error and do not submit form, if value is <= submit the form.
I am 100% lost and do not even know where to start and searching is proving to be little help.
So far the form is php, html and javascript.
have you tried using isset and !empty then doing something with the $_POST data?
function checkForm(form)
{
var spaces = parseInt(form.spaces.value);
var avbspaces = parseInt(form.avbspaces.value);
if(form.spaces.value > form.avbspaces.value) {
alert("Error: There are not enough spaces.");
return false;
}
return true;
}
Within the form:
<FORM NAME="form" id="form" action="submit.php" onsubmit="return checkForm(this);">