X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432..25ef3491bd9ae007ff1fc2b0d7943e6eaaccf775:/docs/source/TextField.html diff --git a/docs/source/TextField.html b/docs/source/TextField.html index d32d2e97..b7f25751 100644 --- a/docs/source/TextField.html +++ b/docs/source/TextField.html @@ -1,55 +1,27 @@ - - - The source code - - - - -
/** + + + The source code + + + + +
/*!
+ * Ext JS Library 3.0.3
+ * Copyright(c) 2006-2009 Ext JS, LLC
+ * licensing@extjs.com
+ * http://www.extjs.com/license
+ */
+
/** * @class Ext.form.TextField * @extends Ext.form.Field *

Basic text field. Can be used as a direct replacement for traditional text inputs, * 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:

*
    - *
  • 1. Field specific validator - *
    - *

    If a field is configured with a {@link Ext.form.TextField#validator validator} function, - * it will be passed the current field value. The {@link Ext.form.TextField#validator validator} - * function is expected to return boolean true if the value is valid or return a string to - * represent the invalid message if invalid.

    - *
  • - *
  • 2. Built in Validation - *
    - *

    Basic validation is affected with the following configuration properties:

    - *
    - * Validation    Invalid Message
    - * {@link Ext.form.TextField#allowBlank allowBlank}    {@link Ext.form.TextField#emptyText emptyText}
    - * {@link Ext.form.TextField#minLength minLength}     {@link Ext.form.TextField#minLengthText minLengthText}
    - * {@link Ext.form.TextField#maxLength maxLength}     {@link Ext.form.TextField#maxLengthText maxLengthText}
    - * 
    - *
  • - *
  • 3. Preconfigured Validation Types (VTypes) - *
    - *

    Using VTypes offers a convenient way to reuse validation. If a field is configured with a - * {@link Ext.form.TextField#vtype vtype}, the corresponding {@link Ext.form.VTypes VTypes} - * validation function will be used for validation. If invalid, either the field's - * {@link Ext.form.TextField#vtypeText vtypeText} or the VTypes vtype Text property will be - * used for the invalid message. Keystrokes on the field will be filtered according to the VTypes - * vtype Mask property.

    - *
  • - *
  • 4. Field specific regex test - *
    - *

    Each field may also specify a {@link Ext.form.TextField#regex regex} test. - * The invalid message for this test is configured with - * {@link Ext.form.TextField#regexText regexText}.

    - *
  • - *
  • Alter Validation Behavior - *
    - *

    Validation behavior for each field can be configured:

      *
    • {@link Ext.form.TextField#invalidText invalidText} : the default validation message to * show if any validation step above does not provide a message when invalid
    • *
    • {@link Ext.form.TextField#maskRe maskRe} : filter out keystrokes before any validation occurs
    • @@ -59,12 +31,11 @@ *
    • {@link Ext.form.Field#validateOnBlur validateOnBlur}, * {@link Ext.form.Field#validationDelay validationDelay}, and * {@link Ext.form.Field#validationEvent validationEvent} : modify how/when validation is triggered
    • - *
    - *
  • *
- * @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, { @@ -152,11 +123,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:

+ *
    + *
  • value: Mixed + *
    The current field value
  • + *
+ *

This function is to Return:

+ *
    + *
  • true: Boolean + *
    true if the value is valid
  • + *
  • msg: String + *
    An error message if the value is invalid
  • + *
*/ validator : null,
/** @@ -235,22 +217,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(); } } @@ -262,9 +235,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 }); } }, @@ -350,9 +332,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(); } }, @@ -384,8 +364,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:

+ *
    + * + *
  • 1. Field specific validator + *
    + *

    A validator offers a way to customize and reuse a validation specification. + * If a field is configured with a {@link #validator} + * function, it will be passed the current field value. The {@link #validator} + * function is expected to return either: + *

      + *
    • Boolean true if the value is valid (validation continues).
    • + *
    • a String to represent the invalid message if invalid (validation halts).
    • + *
    + *
  • + * + *
  • 2. Basic Validation + *
    + *

    If the {@link #validator} has not halted validation, + * basic validation proceeds as follows:

    + * + *
      + * + *
    • {@link #allowBlank} : (Invalid message = + * {@link #emptyText})
      + * Depending on the configuration of {@link #allowBlank}, a + * blank field will cause validation to halt at this step and return + * Boolean true or false accordingly. + *
    • + * + *
    • {@link #minLength} : (Invalid message = + * {@link #minLengthText})
      + * If the passed value does not satisfy the {@link #minLength} + * specified, validation halts. + *
    • + * + *
    • {@link #maxLength} : (Invalid message = + * {@link #maxLengthText})
      + * If the passed value does not satisfy the {@link #maxLength} + * specified, validation halts. + *
    • + * + *
    + *
  • + * + *
  • 3. Preconfigured Validation Types (VTypes) + *
    + *

    If none of the prior validation steps halts validation, a field + * configured with a {@link #vtype} will utilize the + * corresponding {@link Ext.form.VTypes VTypes} validation function. + * If invalid, either the field's {@link #vtypeText} or + * the VTypes vtype Text property will be used for the invalid message. + * Keystrokes on the field will be filtered according to the VTypes + * vtype Mask property.

    + *
  • + * + *
  • 4. Field specific regex test + *
    + *

    If none of the prior validation steps halts validation, a field's + * configured {@link #regex} test will be processed. + * The invalid message for this test is configured with + * {@link #regexText}.

    + *
  • + * * @param {Mixed} value The value to validate * @return {Boolean} True if the value is valid, else false */ @@ -490,6 +532,6 @@ var myField = new Ext.form.NumberField({ } }); Ext.reg('textfield', Ext.form.TextField); -
- +
+ \ No newline at end of file