驗證工具類

2021-08-22 12:16:12 字數 3164 閱讀 9516

public class regexlib

$");

}///

/// 以漢字或字母開頭 、漢字與字母數字組合的名稱,長度為4到16位

///

///

///

public static bool isvalidnickname(string strin)

$");

}///

/// 判斷真實姓名

///

///

///

public static bool isvalidrealname(string strin)

");}

///

/// 驗證郵箱

///

///

///

public static bool isvalidemail(string strin)

///

/// 驗證手機

///

///

///

public static bool isvalidmobile(string strin)

$");

}///

/// author:geek dog

/// content:驗證手機號

/// time:2016-10-31 13:52:44

///

///

///

public static bool isvalidtelphone(string strin)

$");

}///

/// author:geek dog

/// content: 驗證使用者密碼(a-za-z0-9_範圍內6~18位)

/// time:2016-10-31 13:52:14

///

///

///

public static bool isvaliduserpwd(string strin)

$");

}///

/// author:geek dog

/// content:驗證guid (數字字母組合)

/// time:2016-10-31 13:55:27

///

///

public static bool isvalidguid(string strin)

$");

}///

/// author:geek dog

/// content:驗證純數字(最低個位,最高千位)

/// time:2016-10-31 14:06:58

///

///

///

public static bool isvalidnum(string strin)

$");

}///

/// author:geek dog

/// content:驗證純數字(最低個位,最高千位)

/// time:2016-10-31 14:06:58

///

///

///

public static bool isvalidbanknum(string strin)

$");

}///

/// author:geek dog

/// content:驗證url位址

/// time:2016-10-31 13:53:02

///

///

///

public static bool isvalidurladdress(string strin)

[0-9]|[1-9][0-9]|[1-9])\\.(25[0-5]|2[0-4][0-9]|[0-1]"

+ "[0-9]|[1-9][0-9]|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|"

+ "[0-1][0-9]|[1-9][0-9]|[1-9]|0)\\.(25[0-5]|2[0-"

+ "4][0-9]|[0-1][0-9]|[1-9][0-9]|[0-9])|([a-za-z0"

+ "-9\\-]+\\.)*[a-za-z0-9\\-]+\\.[a-za-z])(\\:[0-9]+)?(/"

+ "[^/][a-za-z0-9\\.\\,\\?\\'\\\\/\\+&%\\$\\=~_\\-@]*)*$";

return regex.ismatch(strin, strwhere);

}///

/// 檢驗驗證碼是否合法

///

///

///

public static bool isvalcode(string str)

///

/// 檢驗手機號碼是否合法

///

///

///

public static bool isvalmobilecode(string str)

///

/// 判斷輸入的是否為小數

///

///

///

public static bool isdecimals(string decimals)

public static bool isqq(string qq)

$");

}///

/// 輸入框內容驗證

///

///

///

public static bool getisformtext(string text)

if (text.indexof(">") != -1)

#endregion

#region 防止sql注入式攻擊

string strkeyword = @"select|insert|delete|from|count\(|drop table|update|truncate|asc\(|mid\(|char\(|xp_cmdshell|exec master|netlocalgroup administrators|:|net user|""|or|and";

//過濾關鍵字元

string strregex = @"[-|;|,|/|\(|\)|\[|\]|}|

#endregion

return true;}

Android正則驗證工具類

東西不多,但一般專案夠用了。public class regularutil 1 9 d 0 d 1 0 2 0 1 2 d 3 0 1 d 0 9 x 驗證郵箱 public static final string regex email a z0 9a z a z0 9a z a z0 9a z...

驗證碼工具類 複製

public class getrandompictrue extends baseaction implements ignoreaction 將生成的字母存入到session中 servletactioncontext.getrequest getsession setattribute che...

工具類 傳送簡訊驗證碼

傳送簡訊驗證碼 很簡單的乙個移動端傳送簡訊驗證碼的功能,驗證碼生成及傳送 第三方介面 都是後台完成,本文內容只是從前端通過js傳送請求。var time 30 var interval btnsendverifiedcode click function test cellphone ajax be...