button键点击登录后触发函数 check(),通过id属性接收文本框值,判断完毕后提交from表单
<script type="text/javascript">
function check(){
var storeNo=$("#firstname").val();
if(storeNo!=null && storeNo!=""){
$("#form1").submit();
}else{
alert("用户名密码不能为空");
}
}
</script>
<form class="form-horizontal" role="form" action="store_login.action" method="post" id="form1">
<div class="form-group"><label for="firstname" class="col-sm-2 control-label">店号</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="firstname" name="sm.storeNo"
placeholder="请输入店号">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="button" class="btn btn-default" οnclick="check()">登录</input>
</div>
</div>
</form>