ASP幾個常用的判斷函式

2021-04-01 23:25:58 字數 1026 閱讀 5572

在取得使用者輸入資訊的時候,我們常常要判斷使用者輸入的有效性.

下面幾個是常用的 :

1,檢查輸入字段是否為日期型別

funciton xzip(inputzip)

if isnumeric(inputzip) then

if len(inputzip)=6 then

xzip=1

else 

xzip=0

end if 

else

xzip=0

end if 

end function

3.電子郵件

function xemail(inputemail)

theat=instr(2,inputemail,"@")

if theat=0 then

xemail=0

else

thedot=instr(cint(theat)+2,inputemail,".")

if thedot=0 then 

xemail=0

elseif cint(thedot)+1>len(inputemail)

then

xmail=0

else

xmail=1

end if 

end if

end function

1,先寫指令碼,用if else 判斷**的有效性,

然後將錯誤訊息給乙個變數。

2,用該變數的值來決定網頁的流向和輸出。

還有一種方法是將網頁的提交按扭設為button。

onclick 屬性 觸發子程式。(寫成子程式)

判斷乙個數是奇數還是偶數?

function is_odd(num) as boolean 

n=num mod 2 

if n=1 then 

is_odd=true 

else 

is_odd=false 

end if 

end function 

是奇數返回真,是偶數返回假。

幾個常用的ASP函式

取得帶埠的url,推薦使用 function get scriptnameurl if request.servervariables server port 80 then get scriptnameurl http request.servervariables serve程式設計客棧r na...

asp常用的資料型別判斷函式

用於判斷乙個資料的資料型別,如下 isarray expr 判斷指定表示式expr是否為乙個陣列 isdate expr 判斷指定表示式expr是否可以轉換為日期型別 isempty expr 判斷指定表示式expr是否已經被初始化 isnull expr 判斷指定表示式expr是否是否為空 isn...

ASP中幾個有用的函式

原出處 江都資訊網論壇 function deletefile filename 刪除檔案 if filename then set fso server.createobject scripting.filesystemobject if fso.fileexists filename then ...