亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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

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

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

1.URL地址防注入:

//過(guò)濾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("請(qǐng)勿輸入非法字符");
location.href=sUrl.replace(sQuery,"");
}

2.輸入文本框防注入:

/防止SQL注入

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

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

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

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

相關(guān)文章

最新評(píng)論