I have an application with an Input field which needs to be converted to Uppercase as soon as the User enters a character. This is working as expected.
But if the user tries to enter a character between an already existing word, the cursor is pushed to the end of the Input field. Is there a way I can keep the cursor in the proper location?
Before you down vote, I did check out posts in Stack Overflow and other places. Couldn't find a proper solution. Do provide your feedback.
$(function() {
$("#referenceNo").on('keyup change', function(e) {
$(this).val($(this).val().toUpperCase());
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<label for="referenceNo">Reference No</label>
<br/>
<input type="text" id="referenceNo" name="referenceNo" value="HELLO WORLD!" />
Try to input a character between "Hello World!", the cursor will be pushed to the end of the word. This needs fixing..