X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=lib%2FCGI%2FEx%2Fvalidate.js;h=8ac047976a473c7fc9ab25ca4e8a3906a58958a4;hb=80a766126b7d0281ee013d369d9e6af45cc2cf42;hp=a3b98ebb912a2ce16457fadbd88fba1554542340;hpb=3fe8e76eb82e9d74f656674c5ba913950e166ab1;p=chaz%2Fp5-CGI-Ex diff --git a/lib/CGI/Ex/validate.js b/lib/CGI/Ex/validate.js index a3b98eb..8ac0479 100644 --- a/lib/CGI/Ex/validate.js +++ b/lib/CGI/Ex/validate.js @@ -1,10 +1,10 @@ /**----------------------------------------------------------------*** -* Copyright 2006 - Paul Seamons * +* Copyright 2007 - Paul Seamons * * Distributed under the Perl Artistic License without warranty * * Based upon CGI/Ex/Validate.pm v1.14 from Perl * * For instructions on usage, see perldoc of CGI::Ex::Validate * ***----------------------------------------------------------------**/ -// $Revision: 1.35 $ +// $Revision: 1.41 $ function Validate () { this.error = vob_error; @@ -291,8 +291,10 @@ function vob_validate_buddy (form, field, field_val, N_level, ifs_match) { if (n_values == 0 || (n_values == 1 && values[0].length == 0)) { for (var i = 0; i < tests.length; i ++) { var el = form[field]; + if (! el) continue; var type = el.type; - if (type && (type == 'hidden' || type == 'password' || type == 'text' || type == 'textarea' || type == 'submit')) el.value = values[0] = field_val[tests[i]]; + if (type && (type == 'hidden' || type == 'password' || type == 'text' || type == 'textarea' || type == 'submit')) + el.value = values[0] = '' + field_val[tests[i]]; } } @@ -302,6 +304,8 @@ function vob_validate_buddy (form, field, field_val, N_level, ifs_match) { if (typeof(values[i]) == 'undefined') continue; if (! this.filter_types('do_not_trim',types).length) values[i] = values[i].replace('^\\s+','').replace(new RegExp('\\s+$',''),''); + if (this.filter_types('trim_control_chars',types).length) + values[i] = values[i].replace(new RegExp('\t', 'g'),' ').replace(new RegExp('[\\x00-\\x1F]+','g'),''); if (this.filter_types('to_upper_case',types).length) { values[i] = values[i].toUpperCase(); } else if (this.filter_types('to_lower_case',types).length) {