Hi,
I have a textarea counter which has a limit of 160 characters. What I want to do is when the checkbox is ticked the character limit would charge to 140 characters. I have the following code:
Html:
<input type="checkbox" name="change" value="1" />
<textarea name="sms_text" id="sms_text" rows="8" cols="60" onKeyDown="limitText(this.form.sms_text,this.form.countdown,160);" onKeyUp="limitText(this.form.sms_text,this.form.countdown,160);"></textarea>
<br />
<font size="1">(Maximum characters: 160)<br />
You have <input readonly type="text" name="countdown" size="3" value="160" /> characters left.</font>
Javascript:
function limitText(limitField, limitCount, limitNum) {
if (limitField.value.length > limitNum) {
limitField.value = limitField.value.substring(0, limitNum);
} else {
limitCount.value = limitNum - limitField.value.length;
}
}
Is there any way I could do this? Can someone please help me? Thank you