当表单要求没有满足时,表单onClick运行
Form onClick running when Form required haven't been meet
嘿,家伙们真的不知道怎么说,但即使我已经添加了required
到我的表单输入它运行的JavaScript onsubmit甚至失败的required
当按钮按下和表单空白。
是否有一行我可以添加到我的JavaScript,以阻止它从运行时按下按钮,窗体是空白的?如果有任何帮助就太好了:D
<div id="div3">
<div id="form">
<form action="results.php" method="post" >
<input type="text" id="field" name="field" required>
<input id="submit" name="submit" type="image" src="gif/button.png" onClick="test();" value="submit"></form>
</div><div id="msg"><b>
<span id="msgtxt">Hello</span>
<span id="img"><img src="gif/loadingdot.gif"></span></b>
</div>
</div>
Javascrpt
function test()
{
$('#msg').attr('style','display:block;');
$('#msgtxt').html('Connecting To Server');
setTimeout(function(){ //Beginning of code that should run AFTER the timeout
$('#msgtxt').html('Message one');
//lots more code
},5000); // put the timeout here
setTimeout(function(){ //Beginning of code that should run AFTER the timeout
$('#msgtxt').html('Message two);
//lots more code
},7000); // put the timeout here
setTimeout(function(){ //Beginning of code that should run AFTER the timeout
$('#msgtxt').html('Message three');
//lots more code
},11000); // put the timeout here
setTimeout(function(){
txt=$("#field").val();
$.post("results.php",{field:txt},function(result){
$("#div3").html(result);
});
$('#msg').attr('style','display:none;');
},17000);
}
$(document).ready(function() {
$.post("form.html",{field:'mytext'},function(result){
$("#load").html(result);
});
});
试一试:
<input id="submit" name="submit" type="image" src="gif/button.png" onClick="check();" value="submit">
,然后check();功能:
var check = function(){
if ($("#field").val() != "" )
test();
else
$('#msgtxt').html('form is empty');
}
相关文章:
- 运行时表单发布;t work-jQuery/AAJX/Post
- 在浏览器检查表单之前运行javascript onsubmit
- 如何在表单提交事件后运行JavaScript*
- 在从HTML表单提交时从javascript运行php
- 单击1个表单中的2个提交按钮中的1个时,如何运行脚本
- 在Fancybox中提交表单时运行函数
- 如何在运行总计计算器时返回表单输入并更新 JavaScript 变量
- 在运行时更改表单标签文本
- 在不重新运行jquery验证的情况下检查表单是否有效
- JavaScript/JQuery表单验证运行两次
- 如何在使用JavaScript submit()函数时运行HTML5表单验证
- JQuery val()在设置表单值时引发运行时错误
- 表单提交仅运行Javascript函数一秒钟
- ASP表单在服务器上运行,不允许内部HTML按钮onlick setInterval工作
- 如果未提交表单,则在卸载之前运行窗口功能
- JavaScript 函数未为表单运行
- 带有jQuery提交运行的Javascript表单运行提交两次
- 用于从表单运行PHP脚本的进度条
- HTML/Js表单运行脚本正常
- 在本地测试HTML5登录表单运行良好,但在Phonegap中构建后什么都没有发生