HI in the code down below i have a html setup with buttons for a password input form:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Log in form</title>
<link href="style.css" rel="stylesheet">
<script src="ui.js"></script>
</head>
<body>
<div id="main">
<div id="top_bar"><tx id="tx">Bildschirmsperre</tx></div>
<div id="infotext">Wählen sie Ihre PIN aus</div><br />
<div id="pin"></div><button id="btnback" onclick="changepin(10)">←</button><br />
<div id="tasten">
<button class="button" onclick="changepin(1)">1</button>
<button class="button" onclick="changepin(2)">2</button>
<button class="button" onclick="changepin(3)">3</button><br />
<button class="button" onclick="changepin(4)">4</button>
<button class="button" onclick="changepin(5)">5</button>
<button class="button" onclick="changepin(6)">6</button><br />
<button class="button" onclick="changepin(7)">7</button>
<button class="button" onclick="changepin(8)">8</button>
<button class="button" onclick="changepin(9)">9</button><br />
<button class="button" onclick="changepin(0)">0</button>
</div>
<div id="bottom_bar"> <text id="text_left">ABBRECHEN</text> <zeichen id="zeichen">|</zeichen> <text id="text_right">WEITER</text> </div>
</div>
</body>
</html>
There is no css so it looks awful right now and it contains words in germany so please ignore them.
so far i have this javascript:
var count = 0;
function changepin(value) {
var pin = document.getElementById("pin");
if(value != 10 && count < 4){
pin.innerHTML += value;
count++;
}else if(value == 10){
count--;
pin.innerHTML = pin.value.substr(0, count);
}
}
the typing in (max 4 letters) works fine but i have no idea how to make the backspace i tried a little bit but it isnt working.
Could anyone pls help?
Thanks!