...
|
...
|
@@ -14,27 +14,35 @@ var $ = require('jquery'), |
|
|
* @return {Bool} true/false If the input have danger value
|
|
|
*/
|
|
|
function hasDangerInput(needConvert) {
|
|
|
var $inputs = $('input[type!=hidden], textarea');
|
|
|
|
|
|
var validationPartten = /['"<>&\|]|--/g,
|
|
|
inputs = $('input[type!=hidden], textarea'),
|
|
|
inputsLength = inputs.length;
|
|
|
|
|
|
// to set if the input value should be coverted, and its default value is true;
|
|
|
var willConvert = needConvert === undefined || typeof needConvert !== 'boolean' ? true : needConvert ;
|
|
|
|
|
|
for (var i = 0; i < inputsLength; i++) {
|
|
|
var val = inputs.eq(i).val();
|
|
|
if (validationPartten.test(val)) {
|
|
|
if (willConvert) {
|
|
|
inputs.eq(i).val(val.replace(validationPartten, ' '));
|
|
|
} else{
|
|
|
var matchChars = val.match(validationPartten).join(' ');
|
|
|
tip.show('不可以输入 ' + matchChars + ' 哦!');
|
|
|
inputsLength = $inputs.length,
|
|
|
val,
|
|
|
i,
|
|
|
matchChars,
|
|
|
|
|
|
// to set if the input value should be coverted, and its default value is true;
|
|
|
willConvert = needConvert === undefined || typeof needConvert !== 'boolean' ? true : needConvert;
|
|
|
|
|
|
|
|
|
for (i = 0; i < inputsLength; i++) {
|
|
|
val = $inputs.eq(i).val();
|
|
|
if (validationPartten.test(val)) {
|
|
|
if (willConvert) {
|
|
|
$inputs.eq(i).val(val.replace(validationPartten, ' '));
|
|
|
} else {
|
|
|
matchChars = val.match(validationPartten).join(' ');
|
|
|
tip.show('不可以输入 ' + matchChars + ' 哦!');
|
|
|
}
|
|
|
|
|
|
|
|
|
return !willConvert && true;
|
|
|
}
|
|
|
return !willConvert && true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
|