Search
 
SCRIPT & CODE EXAMPLE
 

HTML

allow only number in input html

HTML5: <input type="number">
Comment

input number only

//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();
    }
}
Comment

HTML text input allow only numeric input

<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(..*?)..*/g, '$1').replace(/^0[^.]/, '0');" />
 Run code snippetHide results
Comment

html input only numbers

<!-- 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: ⬇️ --!>
Comment

PREVIOUS NEXT
Code Example
Html :: html5 progress 
Html :: favicon.ico html 
Html :: How to align input line in html forms 
Html :: discord widget html code 
Html :: span html 
Html :: buttons in bootstrap 
Html :: target vs currenttarget 
Html :: rounded pill bootstrap 5 
Html :: filled input in form 
Html :: html element hover help text 
Html :: cahnge bootstrap navbar color 
Html :: draw vertical line tailwind css 
Html :: input form 
Html :: link href 
Html :: bootstrap country flag dropdown 
Html :: what is rc in version 
Html :: html button click scroll to div 
Html :: tabs characters in html 
Html :: remove action in woocommerce 
Html :: html img onclick 
Html :: html hoover text 
Html :: html select change event 
Html :: how to change submit button size in html 
Html :: creating a table in html 
Html :: multiple form submit for different form action 
Html :: ignor < in html 
Html :: use jquery variable in html 
Html :: html code heavy left arrow 
Html :: Html div element animation example 
Html :: smarty print html 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =