text box accept only numbers in angular code example

Example 1: 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>

Example 2: textbox should accept only numbers till 10 digit using angular

<input type="text" name="country_code" title="Error Message" pattern="[1-9]{1}[0-9]{9}">

Tags:

Html Example