Simulate user writing in a textbox javascript
I have this form and I write into it using:
document.getElementById("val").value ="value";
This inserts the value automatically into the textbox.
Is it possible to insert it simulating user writing? So inserting a letter one by one and not all together?
Solution 1:
Check if this works for you. It will insert the character one by one with delay of around 300ms between each character.
var word = "value";
var n = 0;
var x = document.getElementById("val");
(function loop() {
x.value += word[n];
if (++n < word.length) {
setTimeout(loop, 300);
}
})();
<input type="text" id="val">