I am attempting to automatically replace input from a HTML textarea for specific phrases (for example “a” with “asdf”). My code below works for HTML input boxes, but does not work for textarea. Is there a way to fix it for textarea?
HTML:
<textarea name = "text_input" type="text" id = "text_input"> </textarea>
JS:
$('body').on('input', 'textarea[name=text_input]', function() { $(this).val($(this).val().replace('a', 'asdf')); });
Advertisement
Answer
$('body').on('input', 'textarea[name=text_input]', function() { $(this).val($(this).val().replace('a', 'asdf')); });