Answers for "javascript code to accept only numbers and text in textbox"

5

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

type numeric value only in textbox javascript

<input type="text" class="textfield" value="" id="extra7" name="extra7" onkeypress="return isNumber(event)" />
Posted by: Guest on January-22-2021

Code answers related to "javascript code to accept only numbers and text in textbox"

Browse Popular Code Answers by Language