I would like to know how to create a back button to move back through the characters of an input? I got a backspace to work but am having trouble with moving back without deleting chars.
function setBack(){document.getElementById('someText').value = document.getElementById('someText').value.substring(0, document.getElementById('someText').value.length - 1);}
function setOne(){ document.getElementById('someText').value += "A"; }
function setTwo(){ document.getElementById('someText').value += "B"; }
function moveBack(){document.getElementById('someText').value = document.getElementById('someText').value.substring(0, document.getElementById('someText').value.length - 1);}
.inputUser{
width:55%;
float:left;
margin-top:3%;
border:0px;
overflow-x:scroll;
text-align:left;
border:1px #000000 solid;
}
<input id="someText" class="inputUser" type="text" readonly dir="rtl">
<div>
<button onclick="setOne();">A</button>
<button onclick="setTwo();">B</button>
<button onclick="setBack();">Backspace</button>
<button onclick="moveBack();">back</button>
</div>
No jQuery please. Thank You!