Search
 
SCRIPT & CODE EXAMPLE
 

HTML

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>
Comment

input only accept numbers

<label for="salary">Enter your salary:</label>
<input type="text" id="salary" name="salary"
    oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(..*)./g, '$1');" />
Comment

accept limited numbers in text input

<!-- You can put any number you want in maxlength i.e 4 -->
<input type="text" maxlength="4" onkeypress='return event.charCode >= 48 && event.charCode <= 57'/>
Comment

input only accept numbers

  <input type="number" name="age" id="formAge" maxlength="3" placeholder="age">
Comment

PREVIOUS NEXT
Code Example
Html :: django cannot update static css 
Html :: how to create comments in html5 
Html :: convert ipynb to html 
Html :: how to run an html file from github 
Html :: inspect google remote device disable screencast 
Html :: how to remove fieldset border in html 
Html :: how to add a favicon to html 
Html :: how to add css to html 
Html :: html radio only one checked 
Html :: add html img tag 
Html :: github icon html 
Html :: Description For Page html 
Html :: html button click url 
Html :: javascript remove the current tr with click 
Html :: hambuerger button svg 
Html :: box search bootstrap 
Html :: select placeholder 
Html :: javascript moving text from left to right 
Html :: What is the correct HTML element for playing audio files? 
Html :: img html 
Html :: asp net mvc 5 add logo to navbar 
Html :: html table email template 
Html :: cool css buton 
Html :: html video autosize 
Html :: tailwind css search bar 
Html :: agregar atributo jquery 
Html :: how to make text uppercase html 
Html :: bootstrap 5 navbar not working 
Html :: description list html 
Html :: thymeleaf form delete method 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =