<!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>
jQuery,form表单提交问题。谢谢
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
7条回答 默认 最新
- 斯洛文尼亚旅游 2017-05-25 12:09关注
$("#submit1").submit(function () {
改为
$("#submit1").click(function () {submit是表单的事件,给submit按钮绑定无效,绑定click,return false同样可以阻止表单提交
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥30 Matlab打开默认名称带有/的光谱数据
- ¥50 easyExcel模板 动态单元格合并列
- ¥15 res.rows如何取值使用
- ¥15 在odoo17开发环境中,怎么实现库存管理系统,或独立模块设计与AGV小车对接?开发方面应如何设计和开发?请详细解释MES或WMS在与AGV小车对接时需完成的设计和开发
- ¥15 CSP算法实现EEG特征提取,哪一步错了?
- ¥15 游戏盾如何溯源服务器真实ip?需要30个字。后面的字是凑数的
- ¥15 vue3前端取消收藏的不会引用collectId
- ¥15 delphi7 HMAC_SHA256方式加密
- ¥15 关于#qt#的问题:我想实现qcustomplot完成坐标轴
- ¥15 下列c语言代码为何输出了多余的空格