正则用法验证空格,密码邮箱,验证手机号

判断密码中是否有空格

if (/^[\s ]|[ ]$/gi.test(cryptogram)) {

    alert("密码没有空格哟");

    return false;

  }

验证邮箱

//   验证邮箱

  $("#emailInput").blur(function () {

  var emailInput = $("#emailInput").val()

  var reg = /^([A-z0-9]{6,18})(\w|\-)+@[A-z0-9]+\.([A-z]{2,3})$/

  if(emailInput.trim().length < 1) {

    $("#emailInput").addClass("redWarningInput")

    $("#restWarningPicture").show()

    $("#resetImg").hide()

    $("#noneEmail").html("邮箱为空!")

  } else if(!reg.test(emailInput)) {

    $("#emailInput").addClass("redWarningInput")

    $("#restWarningPicture").show()

    $("#resetImg").hide()

    $("#noneEmail").html("该邮箱不存在")

  } else {

    $("#emailInput").removeClass("redWarningInput")

    $("#restWarningPicture").hide()

    $("#resetImg").show()

    $("#noneEmail").html("")

  }

  });

  // 验证码button是否禁用

  $("#phoneNumber").blur(function () {

  var phoneNumber = $(this).val()

  if (/^[1][3,4,5,7,8][0-9]{9}$/.test(phoneNumber)) {

    $(this).removeClass('redWarningInput')

    $("#successImg1").show()

    $("#forgetWarningPicture").hide()

    $("#forgetPwdWord").html('')

    $("#forgetResetButton").attr('disabled', false);

    $("#forgetResetButton").css("color", "#111111");

    $("#forgetResetButton").click(function () {

    updateCode();

    })

  } else {

    $(this).addClass('redWarningInput')

    $("#forgetWarningPicture").show()

    $("#successImg1").hide()

    $("#forgetPwdWord").html('该手机号不存在')

  }

  }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值