I am trying to insert a specific character say the letter “H” every time a key is pressed in another text box.
Eg.
Text box 1: Type your name
Text box 2: HHHHHHHHHHHHHH
I have tried
$('#cartText16132').keyup( function() {
$('input#test').val('1');
});
But that only inserts one “1”
Hope that makes sense.
The following code should do what you want:
DEMO: http://jsfiddle.net/JhpHL/
Another solution without regular expressions:
DEMO: http://jsfiddle.net/JhpHL/1/