The problem is this: there is a jQuery script

$("#captchaField").on("keypress keydown blur",function (event) { "use strict"; $(this).val($(this).val().replace(/[^\d].+/, "")); if ((event.which < 48 || event.which > 57)) { event.preventDefault();} }); 

It allows you to enter only numbers in the field, but when I try to clear it by pressing backspace or replace it with the current value by selecting a character and try to replace it with another one (I can explain it incomprehensibly, but you can select characters in input and when you press any key with the character input value you selected will be changed to the key symbol). With this script, these features are curtailed. Help get them back.

  • @ splash58 Thank you. What you need. - Eugen Eray
  • @ splash58 digital right is not plowing, 96-105 add - Jean-Claude
  • look here for codes and add exceptions to the ones you need - api.jquery.com/event.which - splash58
  • @ Jean-Claude Ehhhmmm. And figs with her, we're not clerks to use her - Eugen Eray

1 answer 1

You can use the input event. And corrected the regular expression - it resolved one any character after the numbers.

 $(function() { $('#captchaField').on('input', function(event) { $(this).val($(this).val().replace(/[^\d]+/, '')); }); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"> <input type="text" id="captchaField"/> 

  • letters after numbers overwrite field - Jean-Claude
  • And the arrows are beside the input number on the right. - Eugen Eray
  • @EugenEray, updated code. - Alex Zhulin
  • @AlexZhulin Damn I can not check from the phone: ( - Eugen Eray