正则限定输入框输入十六进制数,同时小写改大写

<span id="tipStep1">第一次输入密钥</span>
<span id="tipStep2" style="display:none">第二次输入密钥</span>&nbsp;
<input name="passwordNewText" id="passwordNewText" οnkeyup="toUpperCase(this)" maxLength="32" style="width:20%" />
<input name="passwordConfirmText" id="passwordConfirmText" οnkeyup="toUpperCase(this)" style="display:none" maxLength="32" size="50" />
<label for="userPhone" id="checkPhoneMsg" generated="true" style="background:none;color: #bbb;"></label>

<script src="<%= scriptPath %>jquery-1.7.1.min.js"></script>
<script type="text/javascript">

function registStep1(){
var passwordNew = document.getElementById('passwordNewText').value;
var pattern = /[0-9a-fA-F]{32}$/;
if(passwordNew==''){
$("#checkPhoneMsg").html("请输入密钥");
$("#checkPhoneMsg").css("color","orange");
return ;
}
if(pattern.test(passwordNew)&&passwordNew.length==32){
/* alert("验证通过"); */
$("#checkPhoneMsg").html("");//通过,将错误提示置空
$("#tipStep1").hide();
$("#tipStep2").show();
$("#passwordNewText").hide();
$("#passwordConfirmText").show();
$("#input1").hide();
$("#input2").show();
}else{
/* alert("验证失败"); */
$("#checkPhoneMsg").html("请输入正确的密钥");
$("#checkPhoneMsg").css("color","orange");
return ;
}
}

function registStep2(){
var passwordNew = document.getElementById('passwordNewText').value;
var passwordConfirm = document.getElementById('passwordConfirmText').value;
/* alert(passwordConfirm); */
var pattern = /[0-9a-fA-F]{32}$/;
if(passwordConfirm==''){
$("#checkPhoneMsg").html("请输入密钥");
$("#checkPhoneMsg").css("color","orange");
return ;
}
if(pattern.test(passwordConfirm)&&passwordConfirm.length==32){
/* alert("验证通过"); */
$("#checkPhoneMsg").html("");//通过,将错误提示置空
document.submitForm.passwordNew.value = passwordNew;
document.submitForm.passwordConfirm.value = passwordConfirm;
document.submitForm.submit();
}else{
/* alert("验证失败"); */
$("#checkPhoneMsg").html("请输入正确的密钥");
$("#checkPhoneMsg").css("color","orange");
return ;
}
}
function toUpperCase(obj) //小写转大写,同时去掉非十六进制数
{
obj.value = obj.value.replace(/[^0-9a-fA-F]/g,"");
obj.value = obj.value.toUpperCase();
}
</script>

 

 

转载于:https://www.cnblogs.com/taiguyiba/p/7723810.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值