-<span id='Ext-form-field-Number-cfg-maxText'> /**
-</span> * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to 'The maximum
- * value for this field is {maxValue}')
- */
- maxText : 'The maximum value for this field is {0}',
-
-<span id='Ext-form-field-Number-cfg-nanText'> /**
-</span> * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
- * if a valid character like '.' or '-' is left in the field with no number (defaults to '{value} is not a valid number')
- */
- nanText : '{0} is not a valid number',
-
-<span id='Ext-form-field-Number-cfg-negativeText'> /**
-</span> * @cfg {String} negativeText Error text to display if the value is negative and {@link #minValue} is set to
- * <tt>0</tt>. This is used instead of the {@link #minText} in that circumstance only.
- */
- negativeText : 'The value cannot be negative',
-
-<span id='Ext-form-field-Number-cfg-baseChars'> /**
-</span> * @cfg {String} baseChars The base set of characters to evaluate as valid numbers (defaults to '0123456789').
- */
- baseChars : '0123456789',
-
-<span id='Ext-form-field-Number-cfg-autoStripChars'> /**
-</span> * @cfg {Boolean} autoStripChars True to automatically strip not allowed characters from the field. Defaults to <tt>false</tt>
- */
- autoStripChars: false,
-
- initComponent: function() {
- var me = this,
- allowed;
-
- me.callParent();
-
- me.setMinValue(me.minValue);
- me.setMaxValue(me.maxValue);
-
- // Build regexes for masking and stripping based on the configured options
- if (me.disableKeyFilter !== true) {
- allowed = me.baseChars + '';
- if (me.allowDecimals) {
- allowed += me.decimalSeparator;
- }
- if (me.minValue < 0) {
- allowed += '-';
- }
- allowed = Ext.String.escapeRegex(allowed);
- me.maskRe = new RegExp('[' + allowed + ']');
- if (me.autoStripChars) {
- me.stripCharsRe = new RegExp('[^' + allowed + ']', 'gi');
- }
- }
- },
-
-<span id='Ext-form-field-Number-method-getErrors'> /**
-</span> * Runs all of Number's validations and returns an array of any errors. Note that this first
- * runs Text's validations, so the returned array is an amalgamation of all field errors.
- * The additional validations run test that the value is a number, and that it is within the
- * configured min and max values.
- * @param {Mixed} value The value to get errors for (defaults to the current field value)
- * @return {Array} All validation errors for this field
- */
- getErrors: function(value) {
- var me = this,
- errors = me.callParent(arguments),
- format = Ext.String.format,
- num;
-
- value = Ext.isDefined(value) ? value : this.processRawValue(this.getRawValue());
-
- if (value.length < 1) { // if it's blank and textfield didn't flag it then it's valid
- return errors;
- }
-
- value = String(value).replace(me.decimalSeparator, '.');
-
- if(isNaN(value)){
- errors.push(format(me.nanText, value));
- }
-
- num = me.parseValue(value);
-
- if (me.minValue === 0 && num < 0) {
- errors.push(this.negativeText);
- }
- else if (num < me.minValue) {
- errors.push(format(me.minText, me.minValue));
- }
-
- if (num > me.maxValue) {
- errors.push(format(me.maxText, me.maxValue));
- }
-
-
- return errors;
- },
-
- rawToValue: function(rawValue) {
- var value = this.fixPrecision(this.parseValue(rawValue));
- if (value === null) {
- value = rawValue || null;
- }
- return value;
- },
-
- valueToRaw: function(value) {
- var me = this,
- decimalSeparator = me.decimalSeparator;
- value = me.parseValue(value);
- value = me.fixPrecision(value);
- value = Ext.isNumber(value) ? value : parseFloat(String(value).replace(decimalSeparator, '.'));
- value = isNaN(value) ? '' : String(value).replace('.', decimalSeparator);
- return value;
- },