当我在Eclipse浏览器中运行url时,HTML表单未通过验证

提交电话之前,我必须先执行一种验证形式。当我在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>


白猪掌柜的
浏览 242回答 2
2回答

Qyouu

尝试删除回报的形式标记,并在回调函数返回一个状态码
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript