<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(..*?)..*/g, '$1');" />
HTML5: <input type="number">
//html
<input type="number" class="form-control" @keypress="isNumberKey($event)">
//js
isNumberKey(e){
if (e.charCode === 0 || /d/.test(String.fromCharCode(e.charCode))) {
return true
} else {
e.preventDefault();
}
}
<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(..*?)..*/g, '$1').replace(/^0[^.]/, '0');" />
Run code snippetHide results
<!-- Simply set the input type of the input field to number. --!>
<!-- Just like this: ⬇️ --!>
<!DOCTYPE html>
<html>
<head>
<title>Title/page name</title>
<style>
.css::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
.css::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
{
</style>
</head>
<body>
<p>This input only accepts numbers: </p><input type="number">
<!-- Css can also be use to remove the arrows from the side of the input. --!>
<!-- Just like this: ⬇️ --!>
<p>This input only accepts numbers and has no arrows: </p><input type="number" class="css">
</body>
</html>
<!-- Css can also be use to remove the arrows from the side of the input. --!>
<!-- Just like this: ⬇️ --!>
Code Example |
---|
Html :: html online editor |
Html :: how to combine two input fields in html |
Html :: ng-bind-html vuejs |
Html :: html5 number integer |
Html :: html acronym |
Html :: alpine function |
Html :: how to make option colour black in html |
Html :: title attribute in html |
Html :: html make card |
Html :: w3c valid html boilerplate |
Html :: text in imgae tag html |
Html :: comsumsi api axios |
Html :: how to create check in html? |
Html :: soundcloud player html5 |
Html :: mobile screen ful width not get in html 5 |
Html :: email reply link html |
Html :: html select message |
Html :: html to jade |
Html :: bulleted list html |
Html :: show image only on md screen |
Html :: HTML HOW TO MAKE QUOTE |
Html :: tailwind flex grow 1 |
Html :: coding a classic grid in html |
Html :: <= meaning |
Html :: what is div in html |
Html :: how to scrool some photos in html |
Html :: text input is geeting empty space at start |
Html :: latex in html |
Html :: s9 berlin |
Html :: unyson demo import fail |