I do not know if this option is for you, but there are two ways to "bar" you can do this. using value increments and showing a percentage in the bar. In the case of the example below it determines 60% of 100
Using the progress
tag, the bar shows the evolution of a value, it needs a known total value, and you can make increments. link
<progress value="60" max="100"></progress>
The other option is the meter
tag it determines a percentage of a total. It is not a progress bar, it only shows an X value between a given range , it is used to show when space is occupied on a disk for example. link
<meter value="2" min="0" max="10">3 out of 10</meter><br>
Option with JavaScript
This script only allows you to enter numbers from 0 to 100 in the input, note that they are not 100 characters, but numbers up to the value of 100. And after the input has a span with%. Sometimes it can serve you as well.
function limite(e) {
try {
var element = e.target
} catch (er) {};
try {
var element = event.srcElement
} catch (er) {};
try {
var ev = e.which
} catch (er) {};
try {
var ev = event.keyCode
} catch (er) {};
if ((ev != 0) && (ev != 8) && (ev != 13))
if (!RegExp(/[0-9]/gi).test(String.fromCharCode(ev))) return false;
if (element.value + String.fromCharCode(ev) > 100) return false;
}
window.onload = function () {
document.getElementById('texto').onkeypress = limite
}
input {
font-size: 24px;
width: 3ch; /* largura do campo */
padding-right: 0.25em;
padding-left: 0.25em;
margin-right: 0.5rem;
text-align: right; /* alinha texto a direita */
}
<input type="text" id="texto" maxlength="3" /><span>%</span>