Hello everyone.
I currently have a user on a page called index.php. I want the user to be sent to a page called payment.php if a specified field in a form is empty, if not I want them to receive the error message and still be on the index page and able to enter into the field which was empty.
I have my attempt below but it?s not working. The error is appearing, but the user is still sent to payment.php.
function CheckifEmpty(Amount_field) {
var Amount_entered = document.getElementById(Amount_field);
if (Amount_entered.value == "") {
alert(Error: An amount must be entered.);
return false;
}
return true;
}
And then amidst my main body I have this:
Could anyone tell me what?s wrong with this code:
I currently have a user on a page called index.php. I want the user to be sent to a page called payment.php if a specified field in a form is empty, if not I want them to receive the error message and still be on the index page and able to enter into the field which was empty.
I have my attempt below but it?s not working. The error is appearing, but the user is still sent to payment.php.
function CheckifEmpty(Amount_field) {
var Amount_entered = document.getElementById(Amount_field);
if (Amount_entered.value == "") {
alert(Error: An amount must be entered.);
return false;
}
return true;
}
And then amidst my main body I have this:
Could anyone tell me what?s wrong with this code: