What about adding a valueFilter to replace the trim function. Code fragment: - var result = $.validator.methods[method].call( this, $.trim(element.value), element, rule.parameters ); + var result = jQuery.validator.methods[method].call( this, jQuery.isFunction(this.settings.valueFilter) ? this.settings.valueFilter.apply(this, [element, element.value]) : element.value, element, rule.parameters );
For example, I'd like to trim the full-size space. String.prototype.trim = function() { // \u3000 means wide character space. return this.replace( /^[\s\u3000]+|[\s\u3000]+$/g, "" ); } Then I can set the "valueFilter" setting as(pseudo-code): valueFilter:function() { return $(element).value; } On 8月28日, 上午4时48分, "Jörn Zaefferer" <[EMAIL PROTECTED]> wrote: > Thanks for pointing this out so clearly. Its now fixed in the latest > revision:http://dev.jquery.com/changeset/5841 > The first parameter is now the untrimmed value, so methods that relied > on the trimmed value are now more correct. The required method now > does the necessary trimming. > > Jörn > > On Wed, Aug 27, 2008 at 7:26 PM, Sutra Zhou <[EMAIL PROTECTED]> wrote: > > I think the validation framework should nottrimthe values. > > var result = $.validator.methods[method].call( this, $.trim(element.value), > > element, rule.parameters ); > > ------------------------------------------------------------------------^ > > Should NOTtrimit. > > > And it now caused a bug: > > > In this code: > > //http://docs.jquery.com/Plugins/Validation/Methods/equalTo > > equalTo: function(value, element, param) { > > return value == jQuery(param).val(); > > } > > if there are two input box: input1 and input2. > > the value of input1: "abc " > > the value of input2: "abc " > > then the equalTo returned false. > > This because: > > retun value == jQuery(param).val(); <---------- > > value = "abc"// which is trimmed > > and jQuery(param).value() = "abc " // this is not trimmed. > > The evidences(the test is > > fromhttp://docs.jquery.com/Plugins/Validation/Methods/equalTo):