wuruize888
2017-05-25 10:15
采纳率: 100%
浏览 1.1k
已采纳

jQuery,form表单提交问题。谢谢

 <!DOCTYPE html>

<html>
    <head>
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <script src="jquery.js"></script>
        <script>
            $(function () {
                $("#submit1").submit(function () {    //为什么这里检测都不过,就自动提交了?问题在哪里?谢谢

                    if ($("#dataname").val() === "") {
                        alert("空的无法提交");
                        return false;
                    }
                });
            });
        </script>
    </head>
    <body>
        <div>
            <form action="/pages-search-results.html" class="search nav-form">  
                <div class="input-group input-search">
                    <input type="text" class="form-control" name="q" id="q" placeholder="搜索暂未开通">
                    <span class="input-group-btn"> <button class="btn btn-default" type="submit" id="submits" name="submits"><i class="fa fa-search"></i></button></span>  
                </div>
            </form>

            <form id="MTform" autocomplete="off" method="post" action="config_addmodel">
                <!--           <form id="MTform" name="MTform" autocomplete="off" method="post" action="config_addmodel">-->
                <div>
                    <label>权限编码</label>
                    <div><input type="text" mtype="str:4:15" id="scode" name="scode">
                        <span>请严格按照开发代码填写。</span>
                    </div>
                </div>
                <div>
                    <label for="inputHelpText">主类标记</label>
                    <div><div id="prcls" style="float: left; width:100%;">
                            <!--                            <input type="text" hidden name="model" id="model" value="add">-->
                        </div> 
                        <div id="prcls1" style="float: left; width:100%;">
                            <button type="button" id="newpren">使用新父类</button> 
                            <button type="button" id="oldpren">使用已有子类</button>
                            <div id="newinput"></div>
                            <span></span>
                        </div>
                    </div>
                </div>
                <div> 
                    <label for="inputHelpText">数据库名</label> 
                    <div>
                        <input type="text" id="dataname" name="dataname" mtype="str:4:30">
                        <span>请填写数据库名。</span>
                    </div>
                </div>
                <div> 
                    <label>数据库表名</label> 
                    <div>
                        <input type="text" id="sqlname" name="sqlname" mtype="str:4:30">
                        <span>请填写数据库表名。</span> 
                    </div>
                </div>
                <div> 
                    <label >备注说明</label> 
                    <div>
                        <input type="text" id="remarks" name="remarks" mtype="PHONE:11:30">
                        <span>请填写该功能增加权限时的注意事项。</span> 
                    </div>
                </div>
                <div style="text-align: center;"> 

                    <button type="submit" id="submit1"  class="mb-xs mt-xs mr-xs btn btn-primary" ><i class="fa fa-check-square-o"></i> 提交信息</button> 
                    <button type="reset" style="margin-left: 50px;"><i class="fa fa-undo"></i> 刷新页面</button>
                </div>
            </form>

        </div>
    </body>
</html>

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

7条回答 默认 最新

相关推荐 更多相似问题