js 幾種常用的表單輸入判斷

2021-04-07 07:53:22 字數 1388 閱讀 7891

//函式名:chksafe

//功能介紹:檢查是否含有"'",'//',"/"

//引數說明:要檢查的字串

//返回值:0:是  1:不是

function chksafe(a)

return sum;}

function fucpwdchk(str)

}if (strsource.indexof(ch)==-1)

else }

function jtrim(str)

while (str.charat(str.length-1)==" ")

return(str);

}function chkdate(datestr)

if ((status==0) && (datestr.charat(i)!='-'))

if ((status==1) && (datestr.charat(i)!='-'))

if ((status==2) && (datestr.charat(i)!='-'))

}year=new string (tmpy);

month=new string (tmpm);

day=new string (tmpd)

//tempdate= new string (year+month+day);

//alert(tempdate);

if ((tmpy.length!=4) || (tmpm.length>2) || (tmpd.length>2))

if (!((1<=month) && (12>=month) && (31>=day) && (1<=day)) )

if (!((year % 4)==0) && (month==2) && (day==29))

if ((month<=7) && ((month % 2)==0) && (day>=31))

if ((month>=8) && ((month % 2)==1) && (day>=31))

if ((month==2) && (day==30))

return 1;

}function chkemail(a)}}

return 0;

}//opt1 小數     opt2   負數

//當opt2為1時檢查num是否是負數

//當opt1為1時檢查num是否是小數

//返回1是正確的,0是錯誤的

function chknbr(num,opt1,opt2)

//當最後一位為.時出錯

if (num.charat(i-1)=='.')

for (j=0;j1)

if (num.charat(j)<'0' || num.charat(j)>'9' )}}

return 1;

}補充:

js 幾種常用的表單輸入判斷

函式名 chksafe 功能介紹 檢查是否含有 引數說明 要檢查的字串 返回值 0 是 1 不是 function chksafe a return 0 opt1 小數 opt2 負數 當opt2為1時檢查num是否是負數 當opt1為1時檢查num是否是小數 返回1是正確的,0是錯誤的 funct...

幾種常用的JavaScript表單輸入判斷

函式名 chksafe 功能介紹 檢查是否含有 引數說明 要檢查的字串 返回值 0 是 1 不是 function chksafe a return 0 opt1 小數 opt2 負數 當opt2為1時檢查num是否是負數 當opt1為1時檢查num是否是小數 返回1是正確的,0是錯誤的 funct...

JavaScript 幾種常用的表單輸入判斷

函式名 chksafe 功能介紹 檢查是否含有 引數說明 要檢查的字串 返回值 0 是 1 不是 function chksafe a return 0 opt1 小數 opt2 負數 當opt2為1時檢查num是否是負數 當opt1為1時檢查num是否是小數 返回1是正確的,0是錯誤的 funct...

常用的js判斷

常用的js判斷 關於註冊的時候 對註冊資訊的判斷 表單 引入 下面是對輸入值 還有長度的一個判斷 頁面跳轉重新跳轉到新的頁面 返回首頁 判斷控制元件的可見性 function iscontrolvisible handle else return true 必須輸入字母 function input...

js判斷資料型別的幾種方式

資料型別分為 基礎資料型別和引用 物件 資料型別 基礎資料型別 number string boolean undefined null 常見的引用資料型別 funciton object array 第一種,當資料型別是undefined null 時,可以用 來進行判斷 undefined un...