@@ -173,8 +173,8 @@ var __meta__ = { // jshint ignore:line
173173 that . _downArrowEventHandler . unbind ( "press" ) ;
174174 element
175175 . off ( "keydown" + ns )
176- . off ( "keypress" + ns )
177176 . off ( "keyup" + ns )
177+ . off ( "input" + ns )
178178 . off ( "paste" + ns ) ;
179179
180180 if ( ! readonly && ! disable ) {
@@ -201,9 +201,9 @@ var __meta__ = { // jshint ignore:line
201201
202202 that . element
203203 . on ( "keydown" + ns , proxy ( that . _keydown , that ) )
204- . on ( "keypress" + ns , proxy ( that . _keypress , that ) )
205204 . on ( "keyup" + ns , proxy ( that . _keyup , that ) )
206- . on ( "paste" + ns , proxy ( that . _paste , that ) ) ;
205+ . on ( "paste" + ns , proxy ( that . _paste , that ) )
206+ . on ( "input" + ns , proxy ( that . _inputHandler , that ) ) ;
207207
208208 } else {
209209 wrapper
@@ -514,59 +514,51 @@ var __meta__ = { // jshint ignore:line
514514 var that = this ,
515515 key = e . keyCode ;
516516
517- that . _key = key ;
518-
519517 if ( key == keys . DOWN ) {
520518 that . _step ( - 1 ) ;
519+ return ;
521520 } else if ( key == keys . UP ) {
522521 that . _step ( 1 ) ;
522+ return ;
523523 } else if ( key == keys . ENTER ) {
524524 that . _change ( that . element . val ( ) ) ;
525- } else if ( key != keys . TAB ) {
526- that . _typing = true ;
527- }
528-
529- } ,
530-
531- _keypress : function ( e ) {
532- if ( e . which === 0 || e . metaKey || e . ctrlKey || e . keyCode === keys . BACKSPACE || e . keyCode === keys . ENTER ) {
533525 return ;
534526 }
535527
536- var that = this ;
537- var min = that . options . min ;
538- var element = that . element ;
539- var selection = caret ( element ) ;
540- var selectionStart = selection [ 0 ] ;
541- var selectionEnd = selection [ 1 ] ;
542- var character = String . fromCharCode ( e . which ) ;
543- var numberFormat = that . _format ( that . options . format ) ;
544- var isNumPadDecimal = that . _key === keys . NUMPAD_DOT ;
545- var value = element . val ( ) ;
546- var isValid ;
547-
548- if ( isNumPadDecimal ) {
549- character = numberFormat [ POINT ] ;
528+ if ( key != keys . TAB ) {
529+ that . _typing = true ;
550530 }
531+ that . _cachedCaret = caret ( that . element ) ;
532+ } ,
551533
552- value = value . substring ( 0 , selectionStart ) + character + value . substring ( selectionEnd ) ;
553- isValid = that . _numericRegex ( numberFormat ) . test ( value ) ;
534+ _keyup : function ( ) {
535+ this . _removeInvalidState ( ) ;
536+ } ,
554537
555- if ( isValid && isNumPadDecimal ) {
556- element . val ( value ) ;
557- caret ( element , selectionStart + character . length ) ;
538+ _inputHandler : function ( ) {
539+ var element = this . element ;
540+ var value = element . val ( ) ;
541+ var numberFormat = this . _format ( this . options . format ) ;
542+ var isValid = this . _numericRegex ( numberFormat ) . test ( value ) ;
558543
559- e . preventDefault ( ) ;
560- } else if ( ( min !== null && min >= 0 && value . charAt ( 0 ) === "-" ) || ! isValid ) {
561- that . _addInvalidState ( ) ;
562- e . preventDefault ( ) ;
544+ if ( isValid ) {
545+ this . _oldText = value ;
546+ } else {
547+ this . _blinkInvalidState ( ) ;
548+ this . element . val ( this . _oldText ) ;
549+ if ( this . _cachedCaret ) {
550+ caret ( element , this . _cachedCaret [ 0 ] ) ;
551+ this . _cachedCaret = null ;
552+ }
563553 }
564-
565- that . _key = 0 ;
566554 } ,
567555
568- _keyup : function ( ) {
569- this . _removeInvalidState ( ) ;
556+ _blinkInvalidState : function ( ) {
557+ var that = this ;
558+
559+ that . _addInvalidState ( ) ;
560+ clearTimeout ( that . _invalidStateTimeout ) ;
561+ that . _invalidStateTimeout = setTimeout ( proxy ( that . _removeInvalidState , that ) , 100 ) ;
570562 } ,
571563
572564 _addInvalidState : function ( ) {
@@ -579,6 +571,7 @@ var __meta__ = { // jshint ignore:line
579571 var that = this ;
580572 that . _inputWrapper . removeClass ( STATE_INVALID ) ;
581573 that . _validationIcon . hide ( ) ;
574+ that . _invalidStateTimeout = null ;
582575 } ,
583576
584577 _numericRegex : function ( numberFormat ) {
@@ -752,6 +745,7 @@ var __meta__ = { // jshint ignore:line
752745 }
753746
754747 that . element . val ( value ) ;
748+ that . _oldText = value ;
755749 that . element . add ( that . _text ) . attr ( "aria-valuenow" , value ) ;
756750 } ,
757751
@@ -783,6 +777,7 @@ var __meta__ = { // jshint ignore:line
783777 DOMElement . style . width = "" ;
784778 that . wrapper = wrapper . addClass ( "k-widget k-numerictextbox" )
785779 . addClass ( DOMElement . className )
780+ . removeClass ( 'input-validation-error' )
786781 . css ( "display" , "" ) ;
787782
788783 that . _inputWrapper = $ ( wrapper [ 0 ] . firstChild ) ;
0 commit comments