文件名称:字符验证/** 字符验证/**
文件大小:2KB
文件格式:TXT
更新时间:2015-02-06 18:49:25
字符
/**
* 防范SQL注入漏洞,检测输入的字符
* 需要检测的特殊字符及字符串有:",","-","/","//","'","%","""
* @param strInput 待检测的字符
* @author Tony Lin Added on 2008-10-21
*/
function checkInputChar(strInput){
var forbidChar = new Array(",","-","/","//","'","%","/"");
for (var i = 0;i < forbidChar.length ; i++){
if(strInput.indexOf(forbidChar[i]) >= 0){
alert("您输入的信息: "+strInput+" 中含有非法字符: "+forbidChar[i]+" 请更正!");
return false;
}
}
return true;
}
/**
* 遍历form内元素text类型检测字符合法性,此方法结合 checkInputChar(strInput)使用
* JSP页面只要调用该方法,并传入form名即可自动完成该form内所有元素字符的检测
* @param formName 待检测的form名
* @author Tony Lin Added on 2008-10-21
*/
function validationFormText(formName){
var actionForm;
//alert(typeof(formName));
if(typeof(formName)){
actionForm = formName;
}else{
actionForm = document.forms[0];
}
for (var i=0;i