update the coding format
Showing
1 changed file
with
25 additions
and
17 deletions
@@ -14,27 +14,35 @@ var $ = require('jquery'), | @@ -14,27 +14,35 @@ var $ = require('jquery'), | ||
14 | * @return {Bool} true/false If the input have danger value | 14 | * @return {Bool} true/false If the input have danger value |
15 | */ | 15 | */ |
16 | function hasDangerInput(needConvert) { | 16 | function hasDangerInput(needConvert) { |
17 | + var $inputs = $('input[type!=hidden], textarea'); | ||
18 | + | ||
17 | var validationPartten = /['"<>&\|]|--/g, | 19 | var validationPartten = /['"<>&\|]|--/g, |
18 | - inputs = $('input[type!=hidden], textarea'), | ||
19 | - inputsLength = inputs.length; | ||
20 | - | ||
21 | - // to set if the input value should be coverted, and its default value is true; | ||
22 | - var willConvert = needConvert === undefined || typeof needConvert !== 'boolean' ? true : needConvert ; | ||
23 | - | ||
24 | - for (var i = 0; i < inputsLength; i++) { | ||
25 | - var val = inputs.eq(i).val(); | ||
26 | - if (validationPartten.test(val)) { | ||
27 | - if (willConvert) { | ||
28 | - inputs.eq(i).val(val.replace(validationPartten, ' ')); | ||
29 | - } else{ | ||
30 | - var matchChars = val.match(validationPartten).join(' '); | ||
31 | - tip.show('不可以输入 ' + matchChars + ' 哦!'); | 20 | + inputsLength = $inputs.length, |
21 | + val, | ||
22 | + i, | ||
23 | + matchChars, | ||
24 | + | ||
25 | + // to set if the input value should be coverted, and its default value is true; | ||
26 | + willConvert = needConvert === undefined || typeof needConvert !== 'boolean' ? true : needConvert; | ||
27 | + | ||
28 | + | ||
29 | + for (i = 0; i < inputsLength; i++) { | ||
30 | + val = $inputs.eq(i).val(); | ||
31 | + if (validationPartten.test(val)) { | ||
32 | + if (willConvert) { | ||
33 | + $inputs.eq(i).val(val.replace(validationPartten, ' ')); | ||
34 | + } else { | ||
35 | + matchChars = val.match(validationPartten).join(' '); | ||
36 | + tip.show('不可以输入 ' + matchChars + ' 哦!'); | ||
37 | + } | ||
38 | + | ||
39 | + | ||
40 | + return !willConvert && true; | ||
32 | } | 41 | } |
33 | - return !willConvert && true; | ||
34 | - } | ||
35 | } | 42 | } |
36 | 43 | ||
37 | - return false; | 44 | + |
45 | + return false; | ||
38 | } | 46 | } |
39 | 47 | ||
40 | 48 |
-
Please register or login to post a comment