用了alert和function函数,不出弹框啊?

<html xmlns="http://www.w3.org/1999/xhtml&...
<head runat="server">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>提交</title>

</head>
<body>

<form id="form1" runat="server" action="WebForm25.aspx" onsubmit="return form1Submit();">
    <div>
        <label>
            姓名:
          <input id="nameInput" type="text" />
        </label>
        <input type="submit" value="提交" />
    </div>
</form>
<script type="text/javascript">
    function form1Sumbit() {
        var nameInput = document.getElementById("nameInput");
        if (nameInput.value == "") {
            alert("【请输入姓名】!");
            nameInput.focus();
            return false;
        }
    }
</script>

</body>
</html>
为啥不出弹框呢?求解

阅读 4.9k
3 个回答

楼主拼错名字了吧 Submit...

不弹出?有没有报什么错误?或者用console.log("【请输入姓名】!")调试

你好好检查检查你代码吧!!!!!

<form id="form1" runat="server" action="WebForm25.aspx" onsubmit="return form1Submit();">

function form1Sumbit() {

方法名都不对着!

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题