solid-pixel
6/28/2016 - 9:48 AM

Reduce input text size based on number of characters

Reduce input text size based on number of characters

    jQuery('#target').keypress(function() {

    var textLength = jQuery(this).val().length;

    if(textLength < 10) {
     // Do noting
   } else if (textLength < 13) {
        jQuery(this).css('font-size', '85%');
    } else if (textLength > 16) {
        jQuery(this).css('font-size', '70%');
    }

    //console.log(textLength);
    });