asp檢測郵箱的合法性

2021-04-19 05:13:24 字數 1479 閱讀 2170

<%

dim email

email=request.form("email")

if isvalidemail(email) then

if request("action")="退訂" then

response.redirect "del_email.asp?email="&email

else

response.redirect "add_email.asp?email="&email

end if

else

'response.write "無效的電子郵件格式,請按「後退」按鈕,重填乙個有效的email"

response.write""

end if

function isvalidemail(email)

dim names, name, i, c

'check for valid syntax in an email address.

isvalidemail = true

names = split(email, "@")

if ubound(names) <> 1 then

isvalidemail = false

exit function

end if

for each name in names

if len(name) <= 0 then

isvalidemail = false

exit function

end if

for i = 1 to len(name)

c = lcase(mid(name, i, 1))

if instr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not isnumeric(c) then

isvalidemail = false

exit function

end if

next

if left(name, 1) = "." or right(name, 1) = "." then

isvalidemail = false

exit function

end if

next

if instr(names(1), ".") <= 0 then

isvalidemail = false

exit function

end if

i = len(names(1)) - instrrev(names(1), ".")

if i <> 2 and i <> 3 then

isvalidemail = false

exit function

end if

if instr(email, "..") > 0 then

isvalidemail = false

end if

end function

檢查郵箱合法性

1 標準的c和c 都不支援正規表示式,但有一些函式庫可以輔助c c 程式設計師完成這一功能,其中最著名的當數philip hazel的perl compatible regular expression庫,許多linux發行版本都帶有這個函式庫。2 c c 中使用正規表示式一般分為三步 1 編譯正規...

出棧的合法性檢測

對於乙個給定的入棧順序,可能的出棧順序會有很多,但是肯定都要遵循棧 後進先出 的特點,那麼怎麼進行合法性檢測呢?演算法思想如下 定義變數inindex標記入棧序列的當前位置,定義outindex標記出棧序列的當前位置 對inindex和outindex處的數進行比較,如果相同,同時往後走。如果不相同...

mysql表進行合法性檢查 表單合法性檢測

表單合法性檢測 在處理表單提交的資料的時候,建議盡量採用think model類提供的create方法首先進行資料建立,然後再寫入資料庫。create方法在建立資料的同時,可以進行更為安全的處理操作,而且這一切讓你的表單處理變得更簡單。使用create方法建立資料物件的時候,可以使用資料的合法性檢測...