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>

     
  • 相关阅读:
    Git初级实践教程(图文)
    如何合并多个PPT
    优秀小工具集锦
    VS2015链接错误一则
    VisualStudio配色方案
    AI贪吃蛇(二)
    springMVC
    SSH三大框架的搭建整合(struts2+spring+hibernate)(转)
    生成图片验证码
    Spring JdbcTemplate详解(转)
  • 原文地址:https://www.cnblogs.com/taiguyiba/p/7723810.html
Copyright © 2011-2022 走看看