make only one digit input box

C++
<input type="text" maxlength="1" oninput="this.value=this.value.replace(/[^0-9]/g,'');" />
Source

Also in C++: