I don't know how to split the input in html5, maybe in css you can use the same class to control your input, and you can enter a style, for example:
div{ text-align:center; background:#eee; } input{ border: 0; outline: 0; background: transparent; border-bottom: 2px solid black; width: 100px; text-align:center; padding : 5px; margin-left:10px; } button{ margin-top:20px !important; margin: 0 auto; color: white; border-radius: 4px; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2); }
<div> <input class="form-control" placeholder="0" maxlength="1" /> <input class="form-control" placeholder="0" maxlength="1" /> <input class="form-control" placeholder="0" maxlength="1" /> <input class="form-control" placeholder="0" maxlength="1" /> <br><button type="button" onclick="myFunction()">Submit</button> <p id="optRes"></p> </div>
Define myFunction (), and you can get your array according to your class: form-control, convert to a string, then to int if you need to check it. Does it help?
source share