Input type=password modifies the dot style to *

problem description

modify the password default style to *

the environmental background of the problems and what methods you have tried

related codes

/ / Please paste the code text below (do not replace the code with pictures)

var str = "";

$("input").keyup(function(event){
  var value = $(this).val()
  if(event.keyCode==8){
    str = str.substring(0,value.length)
  }else if(event.keyCode>=49 && event.keyCode <= 90){
    str+= value.substr(value.length-1,1)
  }
  $(this).val(value.replace(/./g,"*"))
})

what result do you expect? What is the error message actually seen?

can be correctly displayed as * * in the input process, but when the input speed is too fast, the actual value of input obtained is not accurate, and when the input speed is slow, it is correct

.
Jun.16,2021

how about this one of mine? The idea is saved and seen is not the same, no cursor flicker of course can make a fake.

http://jsrun.net/z4gKp/edit


you can try input or change events


write

with input event
   $("input").on("input",function(e){
      var value = $(this).val()
      if(event.keyCode==8){
        str = str.substring(0,value.length)
      }else if(event.keyCode>=49 && event.keyCode <= 90){
        str+= value.substr(value.length-1,1)
      }
      $(this).val(value.replace(/./g,'*'))
    });
Menu