<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>
<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');" />
<!-- 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'/>
<input type="number" name="age" id="formAge" maxlength="3" placeholder="age">