zoukankan      html  css  js  c++  java
  • 正则限定输入框输入十六进制数,同时小写改大写

    <span id="tipStep1">第一次输入密钥</span>
    <span id="tipStep2" style="display:none">第二次输入密钥</span>&nbsp;
    <input name="passwordNewText" id="passwordNewText" onkeyup="toUpperCase(this)" maxLength="32" style="20%" />
    <input name="passwordConfirmText" id="passwordConfirmText" onkeyup="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>

     
  • 相关阅读:
    Java注释中的@deprecated与源代码中的@Deprecated
    android KE or NE分析
    Android手机中UID、PID作用及区别
    mtk刷机错误汇总
    区分Integer.getInteger和Integer.valueOf、Integer.parseInt() 的使用方法
    :>/dev/null 2>&1 的作用
    android 小技巧
    转:Eclipse自动补全功能轻松设置
    android开发常用地址
    转:大数据 2016 landscape
  • 原文地址:https://www.cnblogs.com/taiguyiba/p/7723810.html
Copyright © 2011-2022 走看看