javascript - Controlling the display of things typed in text input (with JS)? -


is there way change display of text input js?

for example: input in text field input: "help please"

and want displayed directly typed (within text input as: "help ******"

so second word changed "*****", has keep value when submitted

try utilizing input event , .replace()

var text = "", res = "";    document.queryselector("input").oninput = function() {      this.value = this.value.replace(/p(?=l)|l(?=e)|e(?=a|s)|a|s|e\s/, function(m) {        text += m        return "*"    });        if (this.value.length > 10 && this.value.slice(-2) === "*e") {          text += this.value.slice(-1);      this.value = this.value.replace(/e$/, "*");         res = this.value.slice(0, 5).concat(text);      // stuff `res`      document.queryselector("label").innerhtml = res;      text = res = "";    }    }
<input type="text" /><label></label>


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -