Textarea s obmedzeným počtom znakov
JavaScript -> Ukážkové programy v JavaScripte -> Textarea s obmedzeným počtom znakov
<SCRIPT LANGUAGE="JavaScript">
function CountLeft(field, count, max) {
if (field.value.length > max) field.value = field.value.substring(0, max); else
count.value = max - field.value.length; }
</script>
<form name=sample action="">
<textarea rows="10" cols="40" name="text"
onKeyDown="CountLeft(this.form.text,this.form.left,50);"
onKeyUp="CountLeft(this.form.text,this.form.left,50);">
</textarea>
<br>
Počet zostávajúcich znakov:
<input readonly type="text" name="left" size=3 maxlength=3 value="50">
</form>
function CountLeft(field, count, max) {
if (field.value.length > max) field.value = field.value.substring(0, max); else
count.value = max - field.value.length; }
</script>
<form name=sample action="">
<textarea rows="10" cols="40" name="text"
onKeyDown="CountLeft(this.form.text,this.form.left,50);"
onKeyUp="CountLeft(this.form.text,this.form.left,50);">
</textarea>
<br>
Počet zostávajúcich znakov:
<input readonly type="text" name="left" size=3 maxlength=3 value="50">
</form>