js验证 button 提交
<form class="form-horizontal" role="form" action="member_add" method="post" enctype="multipart/form-data" namespace="/" id="member_add1">
<input type="text" class="form-control" id="jifen" name="member.integral" placeholder="请输入 " onblur="checkjifen();"/>
<button type="button" class="btn btn-primary" id="commit_update1">
提交更改
</button>
</form>
<script>
//积分 数字验证
function checkjifen(){
var check= null;
if ($("#jifen").val().length > 0) {
if (!(/^(\d)*$/.test($("#jifen").val()))) {
$("#jifen").val("");
$("#jifen").attr('placeholder','积分只能为数字');
$("#jifen").focus();
check=false;
} else {
check=true;
}
} else {
$("#jifen").attr('placeholder','积分为空请写0');
$("#jifen").focus();
check=false;
}
return check;
}
function check(){
var check =checkjifen();
return check;
}
$(function(){
$("#commit_update1").click(function(){
if(check()==true){
$("#member_add1").submit();
}
});
});
</script>
</body>