Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
115
rated 0 times [  121] [ 6]  / answers: 1 / hits: 113346  / 11 Years ago, wed, august 14, 2013, 12:00:00

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 validation but also allows to type other alphabets. I can do it by tracking each keydown and matching with regex but I was wondering if there is any way I can restrict to type using only html tags and NOT defining any functions in JavaScript to compare in each keydown?



Code not sufficient to do so is:



    <input type=number id=txt_number maxlength=70 name=txt_name placeholder=Number>


Any help is appreciated.


More From » html

 Answers
9

You can use jquery.numeric plugin.



See
here similar question.



$(document).ready(function(){
$(.numeric).numeric();
});

[#76370] Monday, August 12, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ishmaelw

Total Points: 528
Total Questions: 96
Total Answers: 103

Location: Venezuela
Member since Sat, Apr 24, 2021
3 Years ago
;