X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=lib%2FCGI%2FEx%2Fvalidate.js;h=124cad9dc00bfa64bd4f2f6009af8445f8c76c8a;hb=d0287461de3f9b5c49ce02b22957022bdc5e87d8;hp=a5014afef5d789226419a9055965a986d62f71ab;hpb=4eee158dce82376f2f37de29d91c53f60a24aebe;p=chaz%2Fp5-CGI-Ex diff --git a/lib/CGI/Ex/validate.js b/lib/CGI/Ex/validate.js index a5014af..124cad9 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.34 $ +// $Revision: 1.38 $ function Validate () { this.error = vob_error; @@ -292,7 +292,8 @@ function vob_validate_buddy (form, field, field_val, N_level, ifs_match) { for (var i = 0; i < tests.length; i ++) { var el = form[field]; 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 +303,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) { @@ -1047,7 +1050,8 @@ document.check_form = function (form, val_hash) { document.load_val_hash(form, val_hash); // attach handler - form.onsubmit = function () {return document.validate(this)}; + var orig_submit = form.onsubmit || function () { return true }; + form.onsubmit = function (e) { return document.validate(this) && orig_submit(e, this) }; } // the end //