asp 过滤

来源:互联网 发布:什么软件剪辑视频 编辑:程序博客网 时间:2024/05/02 04:34

asp 过滤非法字符函数

 

<% 
Function cutbadchar(str) 
badstr="不|文|明|字|符|列|表|格|式" 
badword=split(badstr,"|") 
For i=0 to Ubound(badword) 
If instr(str,badword(i)) > 0 then 
str=Replace(str,badword(i),"***") 
End If 
Next 
cutbadchar=str 
End Function 

Response.Write cutbadchar("中国不阿斗发射点发明") 
%>

 

asp去掉html中的table代码函数

 

'去掉html中的table代码
Function OutTable(str)
    dim a,re
    set re=new RegExp
    re.pattern="/<[^>]+()/>"
    re.global=true
    a=str
    OutTable=re.replace(a,"")
End Function

 

asp去掉html,保留img br p div的代码

'去掉html中的table代码
Function OutTable(str)
    dim a,re
    set re=new RegExp
    re.pattern="<(?!img|br|p|div).*?>"
    re.global=true
    a=str
    OutTable=re.replace(a,"")
End Function

 

 ASP中字符串转换成ASCII码

 

函数
function strToAsc(strValue)
dim strTemp
dim i
strTemp=""
for i=1 to len(strValue & "")
strTemp=strTemp & asc(mid(strValue,i,1))
next
strToAsc=strTemp
end function

 

 

JavaScript密码强度在线检测函数

 

<script language=javascript>
function CharMode(iN){
if (iN>=48 && iN <=57) //数字
return 1;
if (iN>=65 && iN <=90) //大写字母
return 2;
if (iN>=97 && iN <=122) //小写
return 4;
else
return 8; //特殊字符
}
function bitTotal(num){
modes=0;
for (i=0;i<4;i++){
if (num & 1) modes++;
num>>>=1;
}
return modes;
}

function checkStrong(sPW){
if (sPW.length<=4)
return 0; //密码太短
Modes=0;
for (i=0;i<sPW.length;i++){
Modes|=CharMode(sPW.charCodeAt(i));
}

return bitTotal(Modes);

}

function pwStrength(pwd){
O_color="#eeeeee";
L_color="#FF0000";
M_color="#FF9900";
H_color="#33CC00";
if (pwd==null||pwd==''){
Lcolor=Mcolor=Hcolor=O_color;
}
else{
S_level=checkStrong(pwd);
switch(S_level) {
case 0:
Lcolor=Mcolor=Hcolor=O_color;
case 1:
Lcolor=L_color;
Mcolor=Hcolor=O_color;
break;
case 2:
Lcolor=Mcolor=M_color;
Hcolor=O_color;
break;
default:
Lcolor=Mcolor=Hcolor=H_color;
}
}

document.getElementById("strength_L").style.background=Lcolor;
document.getElementById("strength_M").style.background=Mcolor;
document.getElementById("strength_H").style.background=Hcolor;
return;
}

</script><table width="770" border="0" align="center" cellpadding="5" cellspacing="0">

<form name="form1" method="post" onSubmit="return checkform(form1);" action="register_add_ok.aspx?url=" autocomplete="off">

<tr>
    <td>登录密码:</td>
    <td><input name="login_passwd" onKeyUp=pwStrength(this.value) onBlur=pwStrength(this.value) type="password" id="login_passwd" size="25" maxlength="50">
      *(长度在5-50之间,建议密码强度为中以上)</td>
  </tr>

 

 Asp检测字符串是否为纯字母和数字组合函数

 

 '******************************
'函数:CheckString(strng)
'参数:strng,待验证字符串
'描述:检测字符串是否为纯字母和数字组合
'示例:<%=CheckString(strng)%>
'******************************
Function CheckString(strng)
    CheckString = true
    Dim regEx, Match
    Set regEx = New RegExp
    regEx.Pattern = "^[A-Za-z0-9]+$"
    regEx.IgnoreCase = True
    Set Match = regEx.Execute(strng)
    if match.count then CheckString= false
End Function

原创粉丝点击