欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JS代碼防止SQL注入的方法(超簡單)

 更新時(shí)間:2016年04月12日 10:15:57   作者:jerrylsxu  
下面通過兩個方面給大家介紹js代碼防止sql注入的方法,非常簡單實(shí)用,感興趣的朋友參考下吧

下面通過兩個方面給大家介紹js代碼防止sql注入的方法,非常簡單實(shí)用,感興趣的朋友參考下吧!

1.URL地址防注入:

//過濾URL非法SQL字符
var sUrl=location.search.toLowerCase();
var sQuery=sUrl.substring(sUrl.indexOf("=")+1);
re=/select|update|delete|truncate|join|union|exec|insert|drop|count|'|"|;|>|<|%/i;
if(re.test(sQuery))
{
alert("請勿輸入非法字符");
location.href=sUrl.replace(sQuery,"");
}

2.輸入文本框防注入:

/防止SQL注入

function AntiSqlValid(oField )
{
re= /select|update|delete|exec|count|'|"|=|;|>|<|%/i;
if ( re.test(oField.value) )
{
//alert("請您不要在參數(shù)中輸入特殊字符和SQL關(guān)鍵字!"); //注意中文亂碼
oField.value = ";
oField.className="errInfo";
oField.focus();
return false;
}

  在需要防注入的輸入文本框添加如下方法

txtName.Attributes.Add("onblur", "AntiSqlValid(this)");//防止Sql腳本注入 

關(guān)于JS代碼防止SQL注入的方法小編就給大家介紹這么多,希望對大家有所幫助!

相關(guān)文章

最新評論