0012628: Deal with empty values in numberfield
authorMichael Spahn <m.spahn@bitexpert.de>
Thu, 9 Feb 2017 10:36:07 +0000 (11:36 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Mon, 27 Feb 2017 10:32:59 +0000 (11:32 +0100)
https://forge.tine20.org/view.php?id=12628

Change-Id: I6a03fb9fb4b43e2e50e6a83271339726f881a492
Reviewed-on: http://gerrit.tine20.com/customers/4270
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Tinebase/js/ux/form/NumberField.js

index 8ce9934..000cdb1 100644 (file)
@@ -121,6 +121,10 @@ Ext.ux.form.NumberField = Ext.extend(Ext.form.NumberField, {
     
     // private, overwrites Ext.form.NumberField.parseValue
     parseValue : function(value){
+        if (!value) {
+            return value;
+        }
+        
         if (this.useThousandSeparator) {
             var regex = new RegExp(((this.thousandSeparator == ".") ? '\\.' : this.thousandSeparator), 'g');
             value = value.replace(regex, '');
@@ -142,18 +146,17 @@ Ext.ux.form.NumberField = Ext.extend(Ext.form.NumberField, {
      * @return {String}
      */
     validateValue: function(value) {
-        
-        if (this.prefix) {
+        if (value && this.prefix) {
             var regex = new RegExp(this.prefix, 'g');
             value = value.replace(regex, '');
         }
         
-        if (this.suffix) {
+        if (value && this.suffix) {
             var regex = new RegExp(this.suffix, 'g');
             value = value.replace(regex, '');
         }
         
-        if (this.useThousandSeparator) {
+        if (value && this.useThousandSeparator) {
             var regex = new RegExp(((this.thousandSeparator == ".") ? '\\.' : this.thousandSeparator), 'g');
             value = value.replace(regex, '');
         }