提交电话之前,我必须先执行一种验证形式。当我在Chrome浏览器中运行网址时,以下代码可以正常运行。但是,当我在eclipse中执行与相同的操作时"Run on server",该表单未通过验证。它带我到本地主机页面。您能帮我解决这个问题吗?提前致谢!
function emptyvalidation(field, errorMessage) {
if (field.value == null || field.value == "") {
alert(errorMessage);
field.focus();
return false;
} else {
return true;
}
}
function validateAndSend() {
if (emptyvalidation(nameField,"Please enter your Name")==false) {nameField.focus(); return false;}
document.getElementById("am_submit").disabled = true;
}
<!DOCTYPE html>
<html>
<div id = "amf" >
<div id = "amTitle" > Enter your form header here </div>
<form onsubmit = "return validateAndSend()" method = "post" target = "_self" name = "amform" id = "amform" action ="http://localhost:8080/api/postForm" autocomplete = "off" >
<div style="margin:6px">
<label style="display:inline-block;width:150px;vertical-align:top">Name:</label>
<input type="text" class="inputBox" id="nameField" name="nameField" value="">
</div>
<div style="margin:6px"></div>
<div class = "ambutton" >
<input type = "submit" class = "am_submit" id = "am_submit" value = "Subscribe" >
</div>
</form>
</div>
</html>
Qyouu
相关分类