Ad

Javascript: Text Area Last Character Is Not Being Capitalized

- 1 answer

Editing a Shopify app. Last character in the text area does not get capitalized on the label picture unless you click outside of text area.

$(function() {
    $('#cstedit-addembossing').keyup(function() {
        this.value = this.value.toUpperCase();
    });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<textarea maxlength="10" data-area="back" class="customify-text" data-target="addembossing" id="cstedit-addembossing" placeholder="Write a name, special date, quote, and the list goes on"></textarea>

Ad

Answer

You probably are looking for a different event than keyup. input works best for what you are trying to do imo.

$(function() {
    $('#cstedit-addembossing').on("input", function() {
        this.value = this.value.toUpperCase();
    });
});
Ad
source: stackoverflow.com
Ad