頁面資料校驗類

2021-06-18 05:07:37 字數 3844 閱讀 2316

///

/// 頁面資料校驗類

///

public class pagevalidate

#region 數字字串檢查

public static bool isphone(string inputdata)

///

/// 檢查request查詢字串的鍵值,是否是數字,最大長度限制

///

/// request

/// request的鍵值

/// 最大長度

/// 返回request查詢字串

/// 是否數字字串

///

/// 輸入字串

///

public static bool isnumber(string inputdata)

///

/// 是否數字字串 可帶正負號

///

/// 輸入字串

///

public static bool isnumbersign(string inputdata)

///

/// 是否是浮點數

///

/// 輸入字串

///

public static bool isdecimal(string inputdata)

///

/// 是否是浮點數 可帶正負號

///

/// 輸入字串

///

public static bool isdecimalsign(string inputdata)

#endregion

#region 中文檢測

///

/// 檢測是否有中文字元

///

///

///

public static bool ishaschzn(string inputdata)

#endregion

#region 郵件位址

///

/// 是否是浮點數 可帶正負號

///

/// 輸入字串

///

public static bool isemail(string inputdata)

#endregion

#region 日期格式判斷

///

/// 日期格式字串判斷

///

///

///

public static bool isdatetime(string str)

else

}catch

} #endregion

#region 其他

///

/// 檢查字串最大長度,返回指定長度的串

///

/// 輸入字串

/// 最大長度

///

public static string sqltext(string sqlinput, int maxlength)

return sqlinput;

}///

/// 字串編碼

///

///

///

public static string htmlencode(string inputdata)

///

/// 設定label顯示encode的字串

///

///

///

public static void setlabel(label lbl, string txtinput)

public static void setlabel(label lbl, object inputobj)

//字串清理

public static string inputtext(string inputstring, int maxlength) 

}retval.replace("'", " ");// 替換單引號

}return retval.tostring();

}///

/// 轉換成 html code

///

/// string

/// string

public static string encode(string str)

///

///解析html成 普通文字

///

/// string

/// string

public static string decode(string str)

public static string sqltextclear(string sqltext)

if (sqltext == "")

sqltext = sqltext.replace(",", "");//去除,

sqltext = sqltext.replace("<", "");//去除<

sqltext = sqltext.replace(">", "");//去除》

sqltext = sqltext.replace("--", "");//去除--

sqltext = sqltext.replace("'", "");//去除'

sqltext = sqltext.replace("\"", "");//去除"

sqltext = sqltext.replace("=", "");//去除=

sqltext = sqltext.replace("%", "");//去除%

sqltext = sqltext.replace(" ", "");//去除空格

return sqltext;

}#endregion

#region 是否由特定字元組成

public static bool iscontainsamechar(string strinput)

return iscontainsamechar(strinput, charinput, strinput.length);

}public static bool iscontainsamechar(string strinput, string charinput, int leninput)

else

])+$", charinput));

//regex regnumber = new regex(string.format("^(})+$", charinput,leninput));

match m = regnumber.match(strinput);

return m.success;}}

#endregion

#region 檢查輸入的引數是不是某些定義好的特殊字元:這個方法目前用於密碼輸入的安全檢查

///

/// 檢查輸入的引數是不是某些定義好的特殊字元:這個方法目前用於密碼輸入的安全檢查

///

public static bool iscontainspecchar(string strinput)

;bool result = new bool();

for (int i = 0; i < list.length; i++)

}return result;

}#endregion

}

頁面資料校驗類

using system using system.text using system.web using system.web.ui.webcontrols using system.text.regularexpressions namespace smarterp.until region 數...

頁面資料校驗

頁面資料校驗類 2010.6 public class pagevalidate request request的鍵值 最大長度 返回request查詢字串 是否數字字串 輸入字串 public static bool isnumber string inputdata 是否數字字串 可帶正負號 輸...

工具類 校驗

手機效驗 正確 true 錯誤 false public boolean ismobile string mobiles matcher m p.matcher mobiles return m.matches 手機格式校驗 11位 正確 true 錯誤 false public boolean i...