Solarpitch Posted January 11, 2007 Share Posted January 11, 2007 Hey Guys,not sure if this is done using JS but you know when a user is typing in a textfield and the limit is set to 300 characters or someting, how do you display the amount of charachter remaing as the user types away? Link to comment https://forums.phpfreaks.com/topic/33721-you-have-x-amount-of-characters-remaining/ Share on other sites More sharing options...
cmgmyr Posted January 11, 2007 Share Posted January 11, 2007 Hey, Try this out...The JS[code]<script>function textCounter(field, countfield, maxlimit) {if (field.value.length > maxlimit) // if too long...trim it! field.value = field.value.substring(0, maxlimit);// otherwise, update 'characters left' counterelse countfield.value = maxlimit - field.value.length;}</script>[/code]The HTML[code]<textarea name="profile" cols="50" rows="10" id="profile" wrap="virtual" onKeyDown="textCounter(this.form.profile,this.form.remLen,300);" onKeyUp="textCounter(this.form.profile,this.form.remLen,300);"></textarea> *</div><input readonly type=text name=remLen size=3 maxlength=3 value="300" ID="Text1">(characters left)[/code]Hope this helps you out.-Chris Link to comment https://forums.phpfreaks.com/topic/33721-you-have-x-amount-of-characters-remaining/#findComment-158179 Share on other sites More sharing options...
Solarpitch Posted January 11, 2007 Author Share Posted January 11, 2007 Thanks . . working at the min, I shall try it later! Thanks a mill! :D Link to comment https://forums.phpfreaks.com/topic/33721-you-have-x-amount-of-characters-remaining/#findComment-158322 Share on other sites More sharing options...
Solarpitch Posted January 11, 2007 Author Share Posted January 11, 2007 Hey man, worked perfect . . . THANK YOU! :D Link to comment https://forums.phpfreaks.com/topic/33721-you-have-x-amount-of-characters-remaining/#findComment-158413 Share on other sites More sharing options...
cmgmyr Posted January 11, 2007 Share Posted January 11, 2007 Hey, not a problem, glad I could help you out!-Chris Link to comment https://forums.phpfreaks.com/topic/33721-you-have-x-amount-of-characters-remaining/#findComment-158438 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.