日期:2014-05-16  浏览次数:20525 次

JS验证
JScript code

<script language="javascript" type="text/javascript">
        function checkInputReal_Name1() {
            var re = /^[\u4e00-\u9fa5]+$/;
            if (re.test(document.getElementById('Real_Name').value)) {

                document.getElementById("needname").style.display = "";
                document.getElementById("name_false").style.display = "none";
                return true;

            } else {


            document.getElementById("name_false").style.display = "";
            document.getElementById("needname").style.display = "none";
            return false;
            
            }
        }
        function checkInputReal_Name2() {
            var re = /^[\u4e00-\u9fa5]+$/;
            if (re.test(document.getElementById('Real_Name').value)) {

                document.getElementById("needname").style.display = "";
                document.getElementById("name_false").style.display = "none";
                return true;


            } else {

            document.getElementById("name_false").style.display = "";
            document.getElementById("needname").style.display = "none";
            return false;
            
            }

        }
        function checkInputReal_Card1() {
            var sf = /(^\d{15}$)|(^\d{17}([0-9]|X)$)/;
            if (sf.test(document.getElementById('Real_Card').value)) {

                document.getElementById("neednum").style.display = "";
                document.getElementById("num_false").style.display = "none";
                return true;
            } else {

                document.getElementById("num_false").style.display = "";
                document.getElementById("neednum").style.display = "none"; onsubmit = "return checkChinese()"
                return false;
            }
        }
        function checkInputReal_Card2() {

            var sf = /(^\d{15}$)|(^\d{17}([0-9]|X)$)/;
            if (sf.test(document.getElementById('Real_Card').value)) {

                document.getElementById("neednum").style.display = "";
                document.getElementById("num_false").style.display = "none";
                return true;
            } else {

                document.getElementById("num_false").style.display = "";
                document.getElementById("neednum").style.display = "none"; onsubmit = "return checkChinese()"
                return false;

            }
        }
    </script>





C# code


 <form id="Form1" runat="server">
            <asp:HiddenField ID="hideActorId" runat="server" />
            <div class="user-right">
                <div class="realName">
                    <h4>
                        实名认证</h4>
                    <div class="con_realName">
                         <dl>
                            <dt>您的真实姓名:</dt>
                            <dd>
                                <input type="text" class="txt_name" id="Real_Name" onmouseout="checkInputReal_Name2()"
                                    onmousedown="checkInputReal_Name1()" />
                                <span class="promptBox" id="needname">真实姓名必须与身份证号匹配,一旦输入后不可轻易更