onsubmit="return check() 给form加onsubmit 验证所有表单后再提交,可以用返回false 来阻止submit提交<form class="form-horizontal form-signin" role="form" onsubmit="return checksame();"><div class="form-group"><label class="col-sm-2 control-label">用户名:</label><div class="col-sm-10"><input type="text" class="form-control" id="" placeholder="用户名" required=''></div></div><div class="form-group"><label for="inputPassword3" name="password" class="col-sm-2 control-label">密码:</label><div class="col-sm-10"><input type="password" class="form-control" id="password" placeholder="请输入密码" required=''></div></div><div class="form-group"><label for="inputPassword3" class="col-sm-2 control-label">密码:</label><div class="col-sm-10"><input type="password" name="password2" class="form-control" id="password2" placeholder="请再输入密码" required=''></div></div><div class="form-group"><label for="inputEmail3" class="col-sm-2 control-label">Email:</label><div class="col-sm-10"><input type="email" class="form-control" id="" placeholder="Email@" required=''></div></div><!-- <div class="form-group"><div class="col-sm-offset-2 col-sm-10"><div class="checkbox"><label><input type="checkbox"> 记住登录状态</label></div></div></div> --><div class="form-group"><label for="inputEmail3" class="col-sm-2 control-label">验证码:</label><div class="col-md-2"><script type="text/javascript">function fleshVerifys(){var time=new Date().getTime();document.getElementById('verifyImg').src='<{:U('Index/verify')}>&'+time;}function checksame(){var pwd1=document.getElementById("password").value;var pwd2=document.getElementById("password2").value;if(pwd1!=pwd2){alert("两次输入的密码不一致!");document.getElementById("password").focus;return false;}else{return true;}}</script><img id="verifyImg" src="<{:U('Index/verify')}>" onclick="fleshVerifys();" /></div><div class="col-md-8"><input type="text" class="form-control" id="" placeholder="请输入验证码" required=''></div></div><div class="form-group"><div class="col-sm-offset-2 col-sm-10"><input type="submit" class="btn btn-lg btn-success" value='注 册'/></div></div></form>
1200字范文,内容丰富有趣,写作的好帮手!