@@ -79,6 +79,7 @@ var reactInputsValidationCss = {
7979} ;
8080var TYPE = 'textbox' ;
8181var VALIDATE_OPTION_TYPE_LIST = [ 'string' , 'number' ] ;
82+ var VALIDATE_NUMBER_TYPE_LIST = [ 'decimal' , 'int' ] ;
8283var DEFAULT_MAX_LENGTH = 524288 ; // Default value is 524288
8384
8485var DEFAULT_AUTO_COMPLETE = 'on' ; // Default value is on
@@ -88,6 +89,7 @@ var getDefaultValidationOption = function getDefaultValidationOption(obj) {
8889 min = obj . min ,
8990 max = obj . max ,
9091 type = obj . type ,
92+ numberType = obj . numberType ,
9193 name = obj . name ,
9294 check = obj . check ,
9395 length = obj . length ,
@@ -104,6 +106,7 @@ var getDefaultValidationOption = function getDefaultValidationOption(obj) {
104106 min = typeof min !== 'undefined' ? min : 0 ;
105107 max = typeof max !== 'undefined' ? max : 0 ;
106108 type = typeof type !== 'undefined' ? type : 'string' ;
109+ numberType = typeof numberType !== 'undefined' ? numberType : 'string' ;
107110 name = typeof name !== 'undefined' ? name : '' ;
108111 check = typeof check !== 'undefined' ? check : true ;
109112 showMsg = typeof showMsg !== 'undefined' ? showMsg : true ;
@@ -119,6 +122,7 @@ var getDefaultValidationOption = function getDefaultValidationOption(obj) {
119122 min : min ,
120123 max : max ,
121124 type : type ,
125+ numberType : numberType ,
122126 name : name ,
123127 check : check ,
124128 length : length ,
@@ -150,7 +154,7 @@ var getDefaultAsyncObj = function getDefaultAsyncObj(obj) {
150154 } ;
151155} ;
152156
153- var autoFormatNumber = function autoFormatNumber ( v ) {
157+ var autoFormatNumber = function autoFormatNumber ( v , numberType ) {
154158 var DOT = '.' ;
155159 var res = '' ;
156160 var hasDot = false ;
@@ -159,15 +163,21 @@ var autoFormatNumber = function autoFormatNumber(v) {
159163
160164 if ( charCode >= 48 && charCode <= 57 || charCode === 46 && ! hasDot ) {
161165 if ( charCode === 46 ) {
166+ if ( numberType === VALIDATE_NUMBER_TYPE_LIST [ 1 ] ) {
167+ return ;
168+ }
169+
162170 hasDot = true ;
163171 }
164172
165173 res += i ;
166174 }
167175 } ) ;
168176
169- if ( res . length && res [ 0 ] === DOT ) {
170- res = "0" . concat ( res ) ;
177+ if ( numberType === VALIDATE_NUMBER_TYPE_LIST [ 0 ] ) {
178+ if ( res . length && res [ 0 ] === DOT ) {
179+ res = "0" . concat ( res ) ;
180+ }
171181 }
172182
173183 return res ;
@@ -289,10 +299,11 @@ var component = function component(_ref) {
289299 }
290300 }
291301
292- var type = option . type ;
302+ var type = option . type ,
303+ numberType = option . numberType ;
293304
294305 if ( type === VALIDATE_OPTION_TYPE_LIST [ 1 ] ) {
295- v = String ( autoFormatNumber ( v ) ) ;
306+ v = String ( autoFormatNumber ( v , VALIDATE_NUMBER_TYPE_LIST . indexOf ( numberType ) >= 0 ? numberType : VALIDATE_NUMBER_TYPE_LIST [ 0 ] ) ) ;
296307 }
297308
298309 setInternalValue ( v ) ;
0 commit comments