You are here: irt.org | FAQ | JavaScript | Form | Q1539 [ previous next ]
Try:
<body onLoad="document.myForm.smsInput.focus()">
<form NAME="myForm">
<input type="text" name="count" value="160" size="3" onFocus="this.blur" readonly>
<br>
<textarea rows="5" cols="50" name="smsInput" wrap
onKeyUp="
val = this.value;
if (val.length > 160) {
alert('Sorry, you are over the limit of 160 characters');
this.value = val.substring(0,160);
smsInput.focus()
}
this.form.count.value=160-parseInt(this.value.length);
"></textarea>
</form>
</body>