<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="jquery-1.9.1.min.js"></script>
<style>
input{
30px;
height:30px;
border: 1px solid black;
text-align: center;
}
</style>
</head>
<body>
<div>
<input type="text">
<input type="text">
<input type="text">
<input type="text">
<input type="text">
<input type="text">
</div>
<script>
inputPw("div")
function inputPw(container){
$(container+" input[type=text]").bind("input",function(){
var val=$(this).val();
var nextVal=$(this).next().val();
if($(this).next().length!=0){
if(nextVal.length==0){
if(val.length==1){
$(this).next().focus()
}
}else{
if(val.length>=2){
$(this).val(val.substring(1))
}
}
}else{
if(val.length>=2){
$(this).val(val.substring(1))
}
}
})
}
</script>
</body>
</html>