SOURCE

console 命令行工具 X clear

                    
>
console
$('#verification').hide();
$('#login').click(function () {
  if ($(":text").val().length == 0) {
    $('#username').focus();
    $("#errorMessage").html(
      "请您填写手机/邮箱/用户名");
  } else if ($(":password").val().length == 0) {
    $('#password').focus();
    $("#errorMessage").html(
         "请您填写密码");
    $('#verification').show();
  } else if ($('#verification').val().length == 0) {
    $('#verification').focus();
    $('#errorMessage').html("请您填写验证码");
  }
});
$('#verification').blur(function () {
  if ($('#username').val().length != 0 && $('#password').val().length != 0) {

  if ($('#verification').val().length == 0) {
    $('#errorMessage').html("请您填写验证码");
  } else if ($('#verification').val() != 'yzm') {
      $("#errorMessage").html(
      "您输入的验证码有误: " + $('#verification').val());
  } else {
    $("#errorMessage").html('');
  }
  }
});
<p id="errorMessage"></p>
  <input id='username' type="text" name="username">
<br/>
  <input type="password" id='password'  name="password">
  <input type='text' id='verification' />
  <br />
  <button id='login'>登录</button>
#errorMessage{
  color:red;
}