0 function CheckPassword() {
var temp = document.getElementById('<%=Password_TextBox.ClientID %>').value;
if (CheckStr(temp ,6,16)){
alert('抱歉!密码字母和数字组合!');
return false;
}
else {
//alert("是");
return true;
}
}
function CheckStr(str, s, e)
{
var m = eval("/^[a-zA-Z0-9_\-]{" + s + "," + e + "}$/");
return m.test(trim(str)); }
function trim(s)
{
return s.replace(/\s/g, "");
}为什么检测的不准确,哪里错了?
this.Password_TextBox.Attributes.Add("onblur", "CheckPassword()");
function CheckPassword() {
var temp = document.getElementById(' <%=Password_TextBox.ClientID %>').value;
if (CheckStr(temp ,6,16)){
alert('抱歉!密码字母和数字组合!');
return false;
}
else {
//alert("是");
return true;
}
}
function CheckStr(str, s, e)
{
var m = eval("/^[a-zA-Z0-9_\-]{" + s + "," + e + "}$/");
return m.test(trim(str)); }
function trim(s)
{
return s.replace(/\s/g, "");
}
</script>
cs文件添加:
this.Password_TextBox.Attributes.Add("onblur", "CheckPassword()");
<script>
function CheckPassword() {
var temp = document.getElementById(' <%=Password_TextBox.ClientID %>').value;
if (CheckStr(temp ,6,16)){
alert('抱歉!密码字母和数字组合!');
return false;
}
else {
//alert("是");
return true;
}
}
function CheckStr(str, s, e)
{
var m = eval("/^[a-zA-Z0-9_\-]{" + s + "," + e + "}$/");
return m.test(trim(str)); }
function trim(s)
{
return s.replace(/\s/g, "");
}
</script>
cs文件添加:
this.Password_TextBox.Attributes.Add("onblur", "CheckPassword()");