手机号不能为空
js:
<input type="text" id = 'phone'>
<button id = 'fs'>发送验证码</button>
<script>
var ofs = document.getElementById('fs');
var ophone = document.getElementById('phone');
ofs.onclick=function () {
if (ophone.value==''){
alert('手机号不能为空')
}else {
alert('发送')
}
}
</script>
jQuery:
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<input type="text" id = 'phone'>
<button id = 'fs'>发送验证码</button>
<script>
$('button').click(function () {
if ($('#phone').val()==''){
alert('手机号不能为空')
}else {
alert('发送')
}
})
</script>