图像弹出后,点击提交按钮处理表单
Image popop after clicking submit button for processing form
我试图使一个弹出图像,当用户点击提交按钮。表单需要一些时间来处理,这就是原因。图像确实弹出得很好。但是表单不会发送。当我删除弹出图像的jQuery时,它会发送表单。
我以一些html开头:
<div id="showProcessingImg">
<input type="submit" name="submit" id="submitForm" value="Send">
</div>
<div id="page-cover">
<div id="uncloseable-lightbox">
</div>
</div>
当然还有一些jQuery:
//POPUP IMAGE
$('#showProcessingImg').click(function() {
$('#submitForm').attr('disabled', true);
$('#saveSignature').attr('disabled', true);
$('#clearSignature').attr('disabled', true);
$('#disablePrev').hide();
$('#page-cover').show();
});
//CHECK IF SIGNATURE IS SAVED
$('#submitForm').click(function() {
if($("#signature").val().length === 0){
alert("Vul eerst een handtekening in en druk op save.");
return false;
} else {
return true;
}
});
最后但并非最不重要的CSS:
#page-cover {
background-color: #888;
display: none;
position: absolute;
left:0;
right:0;
top:0;
bottom:0;
width: 100%;
height: 100%;
opacity: 0.8;
filter: alpha(opacity=80);
}
#uncloseable-lightbox {
background: url(../images/processing.gif) no-repeat !important;
background-size: 320px 70px !important;
position:absolute;
left:50%;
top:40%;
margin-left:-160px;
margin-right:-160px;
width:30%;
height:15%;
}
事件应该在提交按钮上,而不是在它的div包装上。这样的
<div id="showProcessingImg">
<input type="text" name="text" id="signature">
<input type="submit" name="submit" id="submitForm" value="Send">
</div>
<div id="page-cover">
<div id="uncloseable-lightbox">
</div>
</div>
Js:
$('#submitForm').click(function() {
$('#submitForm').attr('disabled', true);
$('#saveSignature').attr('disabled', true);
$('#clearSignature').attr('disabled', true);
$('#disablePrev').hide();
$('#page-cover').show();
if($("#signature").val().length === 0){
alert("Vul eerst een handtekening in en druk op save.");
return false;
} else {
return true;
}
});
Css: #page-cover {
background-color: #888;
display: none;
position: absolute;
left:0;
right:0;
top:0;
bottom:0;
width: 100%;
height: 100%;
opacity: 0.8;
filter: alpha(opacity=80);
}
#uncloseable-lightbox {
background: url(../images/processing.gif) no-repeat !important;
background-size: 320px 70px !important;
position:absolute;
left:50%;
top:40%;
margin-left:-160px;
margin-right:-160px;
width:30%;
height:15%;
}
此处代码:http://jsfiddle.net/harshdand/k54b2Lv5/1/
相关文章:
- 带有验证和隐藏字段值的提交按钮
- 如何在 API 调用后和 if 语句中启用提交按钮
- 提交按钮,该按钮位于使用 Excel VBA 的 Javascript 中
- 如何使用提交按钮搜索表中的记录
- 在单击按钮前后禁用提交按钮
- 在表单完成并确认密码之前,请禁用提交按钮
- 如何使用Java脚本创建提交按钮's的拖放功能
- 如何在单击“提交”按钮时为“新建”窗口编写JavaScript,用“确定”和“取消”显示注册信息
- 提交按钮通过JQuery和JavaScript函数所做的更改不会持续
- 从输入时提交到jQuery,无需提交按钮,无需表单操作
- onclick提交按钮JSP
- 通过提交按钮传递值
- 如果ng单击附加到提交按钮,则表单未验证
- 如何在Razor MVC 5.2.3 Ajax中使用多个提交按钮
- 使用提交按钮隐藏未选中的单选按钮
- Ruby/JS如何在提交按钮后重新加载页面
- JavaScript表单提交没有't fire asp服务器端点击功能的提交按钮
- 使用javascript后,提交按钮不起作用
- 如何使用jQuery/Ajax响应特定的提交按钮
- 表单中的提交按钮在 PHP 打印中不起作用