0
How To show Errors on same page in PhP using javascript for form validations
The form is coffe shop order with the action attribute set to another page which displays the output in php. The form validation has to be done using JavaScript and the error message needs to be displayed on the same page. My problem is that it always goes to the next php page when i click on submit button. Can Anyone please help me out ???
2 ответов
0
javascript
----------------
function validateForm() {
var x = document.forms["myForm"]["name"].value;
if (x == "") {
alert("Name must be filled out");
return false;
}
}
Html form
-------------
<form name="myForm" action="process.php" onsubmit="return validateForm()" method="post">
Name: <input type="text" name="name">
<input type="submit" value="submit">
</form>
0
pre-thankyou...