Compare Page Revisions
« Older Revision - Back to Page History - Current Revision
<input type='text' id='uxFirstNameTextBox' /> <div id='WordsLeft'></div> word(s) left
/*===============================================================================================*/ $(document).ready(function () { setInterval("timerClick()", 300); }); /*===============================================================================================*/ function timerClick() { showWordsLeft("#uxFirstNameTextBox", "#WordsLeft", 100); } /*===============================================================================================*/ function showWordsLeft(inputSelector, outputSelector, maxWords) { var inputField = $(inputSelector); var n = maxWords - getWordCount(inputField.val()); $(outputSelector).html(n); } /*===============================================================================================*/ function getWordCount(s) { s = $.trim(s); if (s.length == 0) return 0; var n = 1; for (i = 0; i < s.length; i++) if (s.charAt(i) == ' ') n++; return n; } /*===============================================================================================*/
ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.