# jQuery Plugin: Input Limiter

Default Textareas This textarea will show the limiter info on two lines
Since this text area is wider it will show the limiter info on one line
Code:

    $('textarea').inputlimiter();

Limit by Words This textarea only allows ten words
Code:

    $('#textarea3').inputlimiter({

    	limit: 10,

    	limitBy: 'words',

    	remText: 'You only have %n word%s remaining...',

    	limitText: 'Field limited to %n word%s.'

    });

Custom limiter text Make it more personal
Code:

    $('#text1').inputlimiter({

    	limit: 50,

    	remText: 'You only have %n character%s remaining...',

    	remFullText: 'Stop typing! You\'re not allowed any more characters!',

    	limitText: 'You\'re allowed to input %n character%s into this field.'

    });

The limiter will display the text in Spanish
Code:

    $('#text2').inputlimiter({

    	limit: 50,

    	remText: '%n caractere%s restantes.',

    	limitText: 'Campo limitado a %n caractere%s.'

    });

The limiter will display the text in French
Code:

    $('#text2_1').inputlimiter({

    	limit: 50,

    	remText: '%n caractère%s restants.',

    	limitText: 'Champ limité à %n caractère%s.',

    	zeroPlural: false

    });

Alternate Box ID This input will display the limiter info in the existing span tag
Field limited to 30 characters.
Code:

    $('#text3').inputlimiter({

    	limit: 30,

    	boxId: 'limitingtext',

    	boxAttach: false

    });

Custom Text Filters The remText and limitText have custom filters
Code:

    $('#text4').inputlimiter({

    	limit: 40,

    	remTextFilter: function (opts, charsRemaining) {

    		var charsTyped = opts.limit - charsRemaining;

    		return "You have typed " + charsTyped + " character" + ( charsTyped == 1?'':'s' ) + ".<br />" +

    			"You have " + charsRemaining + " character" + ( charsRemaining == 1?'':'s' ) + " remaining.";

    	},

    	limitTextFilter: function (opts) {

    		return "This field is limited to " + opts.limit + " character" + ( opts.limit == 1?'':'s' ) + ".";

    	}

    });

When your remaining characters drops below 13 the lyrics from The Twelve Days of Christmas will be displayed.
Code:

    $('#text5').inputlimiter({

    	limit: 12,

    	remTextFilter: function (opts, charsRemaining) {

    		var remText = "The Twelve Days of Christmas";

    		if ( charsRemaining == 12 ) {

    			remText = "Twelve drummers druming.";

    		} else if ( charsRemaining == 11 ) {

    			remText = "Eleven pipers piping.";

    		} else if ( charsRemaining == 10 ) {

    			remText = "Ten lords a' leaping.";

    		} else if ( charsRemaining == 9 ) {

    			remText = "Nine ladies dancing.";

    		} else if ( charsRemaining == 8 ) {

    			remText = "Eight maids a' milking.";

    		} else if ( charsRemaining == 7 ) {

    			remText = "Seven swans a' swimming.";

    		} else if ( charsRemaining == 6 ) {

    			remText = "Six geese a' laying.";

    		} else if ( charsRemaining == 5 ) {

    			remText = "Five gold rings.";

    		} else if ( charsRemaining == 4 ) {

    			remText = "Four calling birds.";

    		} else if ( charsRemaining == 3 ) {

    			remText = "Three french hens.";

    		} else if ( charsRemaining == 2 ) {

    			remText = "Two turtle doves.";

    		} else if ( charsRemaining == 1 ) {

    			remText = "A partridge in a pear tree.";

    		}

    		return remText;

    	}

    });