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 -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -