asp 常用的字符串处理函数
asp 常用的字符串处理函数
Class Cls_Fun
Private x,y,ii
'==============================
'函 数 名:AlertInfo
'作 用:错误显示函数
'参 数:错误提示内容InfoStr,转向页面GoUrl
'==============================
Public Function AlertInfo(InfoStr,GoUrl)
If GoUrl="1" Then
Response.Write "<Script>alert('"& InfoStr &"');location.href='javascript:history.go(-1)';</Script>"
Else
Response.Write "<Script>alert('"& InfoStr &"');location.href='"& GoUrl &"';</Script>"
End If
Response.End()
End Function
'==============================
'函 数 名:HTMLEncode
'作 用:字符转换函数
'参 数:需要转换的文本fString
'==============================
'==============================
'函 数 名:AlertNum
'作 用:判断是否是数字(验证字符,不为数字时的提示)
'参 数:需进行判断的文本CheckStr,错误提示ErrStr
'==============================
Public Function AlertNum(CheckStr,ErrStr)
If Not IsNumeric(CheckStr) or CheckStr="" Then
Call AlertInfo(ErrStr,"1")
End If
End Function
'==============================
'函 数 名:AlertString
'作 用:判断字符串长度
'参 数:
'需进行判断的文本CheckStr
'限定最短ShortLen
'限定最长LongLen
'验证类型CheckType(0两头限制,1限制最短,2限制最长)
'过短提示LongStr
'过长提示LongStr,
'==============================
Public Function AlertString(CheckStr,ShortLen,LongLen,CheckType,ShortErr,LongErr)
If (CheckType=0 Or CheckType=1) And StringLength(CheckStr)<ShortLen Then
Call AlertInfo(ShortStr,"1")
End If
If (CheckType=0 Or CheckType=2) And StringLength(CheckStr)>LongLen Then
Call AlertInfo(LongStr,"1")
End If
End Function
'==============================
'函 数 名:AlertNum
'作 用:判断是否是数字(验证字符,不为数字时的提示)
'参 数:需进行判断的文本CheckStr,错误提示ErrStr
'==============================
Public Function ShowNum(CheckStr,ErrStr)
If Not IsNumeric(CheckStr) or CheckStr="" Then
Response.Write(ErrStr&"|||||")
PageErr=1
End If
End Function
'==============================
'函 数 名:ShowString
'作 用:判断字符串长度
'参 数:
'需进行判断的文本CheckStr
'限定最短ShortLen
'限定最长LongLen
'验证类型CheckType(0两头限制,1限制最短,2限制最长)
'过短提示LongStr
'过长提示LongStr,
'==============================
Public Function ShowString(CheckStr,ShortLen,LongLen,CheckType,ShortErr,LongErr)
If (CheckType=0 Or CheckType=1) And StringLength(CheckStr)<ShortLen Then
Response.Write(ShortErr&"|||||")
PageErr=1
End If
If (CheckType=0 Or CheckType=2) And StringLength(CheckStr)>LongLen Then
Response.Write(LongErr&"|||||")
PageErr=1
End If
End Function
a
'==============================
'函 数 名:BeSelect
'作 用:判断select选项选中
'参 数:Select1,Select2
'==============================
Public Function BeSelect(Select1,Select2)
If Select1=Select2 Then
BeSelect=" selected='selected'"
End If
End Function
'==============================
'函 数 名:BeCheck
'作 用:判断Check选项选中
'参 数:Check1,Check2
'==============================
Public Function BeCheck(Check1,Check2)
If Check1=Check2 Then
BeCheck=" checked='checked'"
End If
End Function
- 上一篇:sp判断中西混字符串长度
- 下一篇:asp 简单数据库连接类