手机号不能为空

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>

posted @ 2018-03-06 10:08  璁璁那~年  阅读(846)  评论(0编辑  收藏  举报