当input的框全部不为空时,提交按钮变色

<body>
<form class="cmxform" id="commentForm" method="get" action="">
<fieldset>
<p class="phone">
<label for="cname">账号</label>
<input id="cname" name="name" minlength="11" type="number" placeholder="请输入手机号" required>
</p>
<p class="oldpassword phone">
<label for="cpass">旧密码</label>
<input type="password" name="cpass1" id="cpass1" minlength="6">
</p>
<p class="newpassword phone">
<label for="cpass">新密码</label>
<input type="password" name="cpass" id="cpass" minlength="6">
</p>
<div id="submit" class="submit"><a id="submit-a" href="#">完成</a></div>
</fieldset>
</form>
</body>
<script>
//获取验证码
var request;
//当所有input框不为空时,按钮变色
$('input').on('input propertychange', function() {
if(($.trim($('#cname').val()) !== "") && ($.trim($('#cpass1').val()) !== "") && ($.trim($('#cpass').val()) !== "")){
$(".submit").css("background-color","#5fcdd7");
} else {
$(".submit").css("background-color","#d1d1d1");
}
});
</script>

posted on 2017-09-30 15:21  share水边  阅读(553)  评论(0编辑  收藏  举报

导航