几乎标题一切正常,但问题是当我按下提交时,即使 JavaScript 函数返回,它也会调用 PHP 函数false
。
<script >
function validateForm(){
var formData = document.forms["Signup Form"]["FirstName"].value;
var div = document.getElementById("FirstNameDiv")
if(formData==null || formData=="")
{
div.innerHTML = "<p>" + "invalid" + "</p>"
return false;
}
return true;
}
</script>
<form name="Signup Form" method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" onsubmit="return validateForm();" ) ">