[jQuery] Better way to trim whitespace from input?
Hi,
I need to transform all characters entered in an input field to
uppercase and trim trailing whitespace. This script works, but I'm
wondering if there's a better way to do it.
<script>
$(document).ready(function(){
$("input").keyup(function (e) {
$("#couponCode").val($(this).val().toUpperCase());
});
$("button").click(function () {
var couponCode = $("#couponCode").val();
couponCode = jQuery.trim(couponCode);
});
});
</script>
Any suggestions?
Thanks in advance.