常用後端正則校驗
單單前端校驗是不安全的,所以後端的校驗同樣必不可少。
後端正則檢驗表單
public void GetValidate()
{
string email = Request["email"];
if (!Regex.IsMatch(email, @"^[w-] (.[w-] )*@[w-] (.[w-] ) $"))
{
Page.RegisterStartupScript("test", "<script>alert(`郵箱格式不正確!`);window.history.go(-1);</script>");
return;
}
string phone = Request["phone"];
if (!Regex.IsMatch(phone, @"^[1][3-8]d{9}$"))
{
Page.RegisterStartupScript("test", "<script>alert(`手機號碼格式不正確!`);window.history.go(-1);</script>");
return;
}
string phone = Request["phone"];
if (!Regex.IsMatch(phone, @"d{3,4}-d{7,8}") && !Regex.IsMatch(phone, @"^[1]d{10}"))
{
Page.RegisterStartupScript("test", "<script>alert(`電話號碼格式不正確!`);window.history.go(-1);</script>");
return;
}
string shopprice = Request["shopprice"];
if (!Regex.IsMatch(shopprice, @"^(([0-9]|([1-9][0-9]{0,9}))((.[0-9]{1,2})?))$"))
{
Page.RegisterStartupScript("test", "<script>alert(`金額格式不正確!`);window.history.go(-1);</script>");
return;
}
string shopstore = Request["shopstore"];
if (!Regex.IsMatch(shopstore, @"^(0|[1-9]d*)$"))
{
Page.RegisterStartupScript("test", "<script>alert(`庫存格式不正確!`);window.history.go(-1);</script>");
return;
}
}
相關文章
- 前端Vue中常用rules校驗規則前端Vue
- 前端 - 開發中常用的正則校驗前端
- element-ui自定義表單校驗規則及常用表單校驗UI
- Vue中form表單常用rules校驗規則VueORM
- 前端正則二三事前端
- springMVC:校驗框架:多規則校驗,巢狀校驗,分組校驗;ssm整合技術SpringMVC框架巢狀SSM
- 前端資料校驗後,後端介面是否需要再次校驗?前端後端
- 校驗檔案的搜尋規則
- SpringBoot專案校驗規則優化Spring Boot優化
- sentinel流控規則校驗之原始碼分析原始碼
- 前端與後端TP的資料校驗前端後端
- element-ui 表單校驗 Rules 配置 常用黑科技UI
- Java-Bean Validation後端校驗總結JavaBean後端
- Vue Element-ui表單校驗規則,你掌握了哪些?VueUI
- 【勝通 】mysql字符集與校驗規則的設定MySql
- Spring boot 生成動態驗證碼並前後端校驗Spring Boot後端
- jwt加meta元資訊實現登入後校驗JWT
- 前後端實現登入token攔截校驗後端
- 行式填報 資料校驗 --- 小計校驗
- ios下引用MUI後input不能輸入,Android端正常iOSUIAndroid
- CRC校驗原理
- 資料校驗
- 分組校驗
- php開發中經常用到的正則驗證PHP
- PHP獲取IMEI號最後一位校驗碼PHP
- 檔案下載時前後臺MD5校驗
- 【勝通】mysql連線通道中的字符集和校驗規則MySql
- 關於laravel使用自定義驗證規則後某些規則不生效Laravel
- SpringBoot分組校驗及自定義校驗註解Spring Boot
- 三無選手上岸大廠的後端校招經驗後端
- Angular8 form 表單對隱藏元素取消表單校驗規則AngularORM
- laravel 校驗規則 Rule::in 等對中文字元不友好的問題Laravel字元
- JS 校驗非法字串JS字串
- eslint 校驗去除EsLint
- easypoi資料校驗
- CRC的校驗原理
- 淺談奇偶校驗
- AOP 無感校驗