[英]How to off the Bootstrap Loading Button while text is still Empty
请帮助我在我的文本框仍然为空的情况下关闭引导加载按钮,用户需要在提交按钮将文本更改为加载之前填充所有文本框
我发生的事情是,当用户单击“提交”按钮时,引导程序也正在加载,即使页面文本框仍具有必填字段。
这是我当前的代码
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap-theme.min.css">
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<script type="text/javascript">
$(function() {
$(".btn").click(function(){
$(this).button('loading').delay(1000).queue(function() {
$(this).button('reset');
$(this).dequeue();
});
});
});
</script>
<form class="form-horizontal" action="button.php" method="post" style=" width:450px;">
<label class="control-label col-xs-3">Username Name :</label>
<input type="textbox" class="form-control" name="txtfirst" placeholder="First Name"required>
<label class="control-label col-xs-3">Password :</label>
<input type="textbox" class="form-control" name="txtlast" placeholder="Last Name"required>
<button type="submit" class="btn btn-primary" data-loading-text=" Loading... ">Login</button>
</form>
请帮忙
从代码看来,您的js函数调用绑定到按钮的click事件,而不是表单的Submit事件。 click事件不执行任何表单验证。
试试这个: http : //jsfiddle.net/Dde4U/
$(function() {
$(".btn").click(function(){
if($('.form-horizontal').valid()){ //Checks if form is valid
$(this).button('loading').delay(1000).queue(function() {
$(this).button('reset');
$(this).dequeue();
});
}
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.