Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
105
rated 0 times [  109] [ 4]  / answers: 1 / hits: 18606  / 11 Years ago, thu, march 14, 2013, 12:00:00

Is there any simple way I can use to prevent user from accepting numeric values in html textbox? I've encountered some features of HTML5 like type=email etc...



Now is there any feature for accepting only character values?


More From » html

 Answers
31

I would do like that with jQuery :



JQuery



$(#only-text).on('keyup', function(e) {
var val = $(this).val();
if (val.match(/[^a-zA-Z]/g)) {
$(this).val(val.replace(/[^a-zA-Z]/g, ''));
}
});


See the working fiddle.


[#79593] Wednesday, March 13, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ravenl

Total Points: 338
Total Questions: 107
Total Answers: 112

Location: Belize
Member since Mon, Jun 20, 2022
2 Years ago
ravenl questions
Thu, Feb 18, 21, 00:00, 3 Years ago
Tue, Jan 12, 21, 00:00, 3 Years ago
Tue, Mar 17, 20, 00:00, 4 Years ago
;