精美而实用的网站,关注web编程技术、网站运营、SEO推广,让您轻松愉快的学习

本ASP函数用来检测用户输入的密码是否符合规定,也就是是否符合带有下划线、字母有数字的格式,用来检测客户输入的密码是否合法可以。

ASP正则判断密码只能输入字母数字下划线

Public Function CheckPassword(Str)
  Dim pass
  CheckPassword=true
  If Str <> "" Then
   Dim Rep
   Set Rep = New RegExp
   Rep.Global = True
   Rep.IgnoreCase = True
   '匹配字母、数字、下划线、点号
   Rep.Pattern="[a-zA-Z0-9_\.]+$"
   Pass=rep.Test(Str)
   Set Rep=nothing
   If not Pass Then CheckPassword=false
   End If
 End Function

青岛星网温馨提醒:函数返回值:true无误,false有误。

Tags:ASP 正则 函数