<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">
Code Example |
---|
Html :: bootstrap large text clip |
Html :: how to use pyscript in html |
Html :: how to put image center in html stack overflow |
Html :: Checkbox checked border radius CSS |
Html :: load pdf html |
Html :: copyright symbol html |
Html :: html input radio |
Html :: codewithmarley |
Html :: select tag html |
Html :: bootstrap color class |
Html :: nuxt cursor focus |
Html :: meta tags html |
Html :: html redirect |
Html :: html dropdown |
Html :: if else handlebars |
Html :: square div |
Html :: div table bootstrap 4 |
Html :: whitespace code |
Html :: open new tab href |
Html :: how to change font html |
Html :: html href to gmail |
Html :: bold text on HTML button |
Html :: mat-tab-group change |
Html :: bootstrap nav search form |
Html :: require in html |
Html :: html entity at sign |
Html :: html input submit size width |
Html :: bootstrap 4 6 cdn |
Html :: html video loop |
Html :: add csrf token in vuejs |