Answers for "make input text accept only numbers attribute"

3

accept only numbers in textbox

<input type="text" onkeypress="return isNumberKey(event)" placeholder="Phone Number">
//this will accept only numbers from 0 to 9
<script>
function isNumberKey(evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode
	if (charCode > 31 && (charCode < 48 || charCode > 57))
	return false;

	return true;
}
</script>
Posted by: Guest on December-19-2020
0

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: ⬇️ --!>
Posted by: Guest on April-05-2022

Code answers related to "make input text accept only numbers attribute"

Browse Popular Code Answers by Language