When entering the card number and code in the input fields, the last number is always replaced if the input is continued. How to cancel it?

Maybe somewhere here:

 function checkMaxInput(){ var max = $(this).data('max'); var keyCode = event.keyCode; if( keyCode!=key_code_map.backspace && keyCode!=key_code_map.delete && keyCode!=key_code_map.go && keyCode!=key_code_map.next && this.value.length==max ) { this.value = this.value.slice(0,-1) } }; 

Full code

UPD

It is necessary that when entering the maximum number, the input is stopped, and the replacement of the last number does not occur. Those. it is necessary to do this: when the last maximum digit is entered in input, no input takes place when the numbers are dialed further.

    1 answer 1

     this.value = this.value.slice(0,-1) 

    This line cuts the value of the input by one character from the end.

    In this case, the check for the maximum number of characters in the input + is checked which keys are pressed (processing backspace-a , delete-а )

    Try to comment out this line, see what happens, or describe what kind of behavior you need if you exceed the maximum length of the input value.

    • it is necessary that when entering the maximum number, the input is stopped, and the replacement of the last number does not occur. those. when the last maximum digit in input is entered, no further input will be made upon a further set of numbers. - Marina Voronova
    • About this.value = this.value.slice(0,-1) it is impossible to comment. I can’t explain exactly, but this code is needed for editing to take place correctly, without it the carriage goes to the beginning or to the middle of the line - Marina Voronova