I need to have a textbox, where, whenever typed inside should ONLY allow numbers [0-9]. I\'ve used type=\"number\"
which definitely holds the client side valida
You will have to have your input box inside a form and with a submit button. The form validation happens at the submission of the form. See a demo here: http://jsfiddle.net/ds345/Q4muA/1/
<form>Number:
<input type="number" name="Number" value="10">
<br>
<input type="submit" value="Submit" />
</form>
Try this:-
$("#txtAge").keydown(function (e) {
if(e.key=='e' || e.key=='.' || e.key=='-')
return false;
});
Browsers behave differently. In Chrome the following code:
<input type="number" id="txt_number" maxlength="70" name="txt_name" placeholder="Number">
<input type="submit">
will work for you only if it is in a form and only after the user clicks the submit button.