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
Post a Comment