How can I make to accept only numbers inputs in my code: -->>
Here ?
Thank you !
You can do this:
<input type="number">
or this:
<input type="text" pattern="[0-9]+">
These will only work in HTML5 compatible browsers.
In javascript you can do this:
HTML:
<input type="text" id="test" name="test"/>
CSS:
var input = document.getElementById("test");
input.oninput = function(e){
if (/\D/g.test(this.value))
{
// Filter non-digits from input value.
this.value = this.value.replace(/\D/g, '');
}
}