SyntaxFix
Write A Post
Hire A Developer
Questions
You can use \D which means non digits.
\D
var removedText = self.val().replace(/\D+/g, '');
jsFiddle.
You could also use the HTML5 number input.
<input type="number" name="digit" />