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">真实姓名必须与身份证号匹配,一旦输入后不可轻易更改</span> <span class="warningBox"
id="name_false" style="display: none;">请正确输入您的真实姓名(仅支持2-10个中文)</span>
</dd>
</dl>
<dl>
<dt>您的身份证号:</dt>
<dd>
<input type="text" class="txt_num" id="Real_Card" onmousedown="checkInputReal_Card1()" onmouseout="checkInputReal_Card2()"/>
<span class="promptBox" id="neednum">身份证号有15/18位数字或字母组成</span> <span class="warningBox"
id="num_false" style="display: none;">请正确填写您的身份证号(15/18位数字或字母组成)</span>
</dd>
</dl>
<input type="image" src="images/realname_submit.gif" />
</div>
</div>
</div>
</form>