X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432..25ef3491bd9ae007ff1fc2b0d7943e6eaaccf775:/src/widgets/form/TextField.js diff --git a/src/widgets/form/TextField.js b/src/widgets/form/TextField.js index 2ecaa217..aed69ebb 100644 --- a/src/widgets/form/TextField.js +++ b/src/widgets/form/TextField.js @@ -1,5 +1,5 @@ /*! - * Ext JS Library 3.0.0 + * Ext JS Library 3.0.3 * Copyright(c) 2006-2009 Ext JS, LLC * licensing@extjs.com * http://www.extjs.com/license @@ -11,44 +11,10 @@ * or as the base class for more sophisticated input controls (like {@link Ext.form.TextArea} * and {@link Ext.form.ComboBox}).

*

Validation

- *

Field validation is processed in a particular order. If validation fails at any particular - * step the validation routine halts.

+ *

The validation procedure is described in the documentation for {@link #validateValue}.

+ *

Alter Validation Behavior

+ *

Validation behavior for each field can be configured:

*
- * @constructor - * Creates a new TextField + * + * @constructor Creates a new TextField * @param {Object} config Configuration options + * * @xtype textfield */ Ext.form.TextField = Ext.extend(Ext.form.Field, { @@ -151,11 +116,22 @@ var myField = new Ext.form.NumberField({ */ blankText : 'This field is required', /** - * @cfg {Function} validator A custom validation function to be called during field validation + * @cfg {Function} validator + *

A custom validation function to be called during field validation ({@link #validateValue}) * (defaults to null). If specified, this function will be called first, allowing the - * developer to override the default validation process. This function will be passed the current - * field value and expected to return boolean true if the value is valid or a string - * error message if invalid. + * developer to override the default validation process.

+ *

This function will be passed the following Parameters:

+ *
+ *

This function is to Return:

+ *
*/ validator : null, /** @@ -234,22 +210,13 @@ var myField = new Ext.form.NumberField({ this.validationTask = new Ext.util.DelayedTask(this.validate, this); this.mon(this.el, 'keyup', this.filterValidation, this); } - else if(this.validationEvent !== false){ + else if(this.validationEvent !== false && this.validationEvent != 'blur'){ this.mon(this.el, this.validationEvent, this.validate, this, {buffer: this.validationDelay}); } - if(this.selectOnFocus || this.emptyText){ - this.on('focus', this.preFocus, this); - - this.mon(this.el, 'mousedown', function(){ - if(!this.hasFocus){ - this.el.on('mouseup', function(e){ - e.preventDefault(); - }, this, {single:true}); - } - }, this); + if(this.selectOnFocus || this.emptyText){ + this.mon(this.el, 'mousedown', this.onMouseDown, this); if(this.emptyText){ - this.on('blur', this.postBlur, this); this.applyEmptyText(); } } @@ -261,9 +228,18 @@ var myField = new Ext.form.NumberField({ this.mon(this.el, 'click', this.autoSize, this); } if(this.enableKeyEvents){ - this.mon(this.el, 'keyup', this.onKeyUp, this); - this.mon(this.el, 'keydown', this.onKeyDown, this); - this.mon(this.el, 'keypress', this.onKeyPress, this); + this.mon(this.el, { + scope: this, + keyup: this.onKeyUp, + keydown: this.onKeyDown, + keypress: this.onKeyPress + }); + } + }, + + onMouseDown: function(e){ + if(!this.hasFocus){ + this.mon(this.el, 'mouseup', Ext.emptyFn, this, { single: true, preventDefault: true }); } }, @@ -349,9 +325,7 @@ var myField = new Ext.form.NumberField({ el.removeClass(this.emptyClass); } if(this.selectOnFocus){ - (function(){ - el.dom.select(); - }).defer(this.inEditor && Ext.isIE ? 50 : 0); + el.dom.select(); } }, @@ -383,8 +357,70 @@ var myField = new Ext.form.NumberField({ }, /** - * Validates a value according to the field's validation rules and marks the field as invalid - * if the validation fails + *

Validates a value according to the field's validation rules and marks the field as invalid + * if the validation fails. Validation rules are processed in the following order:

+ *