StandardFloatField.js
1.08 KB
Ext.define('amdaUI.StandardFloatField', {
extend: 'Ext.form.field.Text',
xtype: 'standardfloatfield',
// Additional configurations and custom logic can be added here
regex: /[-+]?(?:\d*\.?\d+|\d+\.?\d*)(?:[eE][-+]?\d+)?/,
min:-Number.MAX_VALUE,
max: Number.MAX_VALUE,
initComponent: function () {
this.callParent();
// Set up validation and change event handling
this.validator = this.createValidator();
},
createValidator: function () {
var me = this;
return function (val) {
var errMsg = null;
if (!me.allowBlank && Ext.isEmpty(val)) {
errMsg = 'Blank value not allowed';
} else if ((typeof me.min !== 'undefined' && me.min !== null) && (parseFloat(val) < me.min)) {
errMsg = 'Min. allowed value is ' + me.min;
} else if ((typeof me.max !== 'undefined' && me.max !== null) && (parseFloat(val) > me.max)) {
errMsg = 'Max. allowed value is ' + me.max;
}
return errMsg ? errMsg : true;
};
},
});