Forum Moderators: open
<script type="text/javascript">function CheckSize(form, field) {
if (field ==1) {
Ctrl = form.comments;
y = 300+1;
}
else {
Ctrl = form.longdescription;
y=300;
}
x = Ctrl.value.length;
if (x < y)
SendMsg (Ctrl, "Number of characters is: " + x); else
SendMsg (Ctrl, "Warning! Description Too Long. Number of characters is: " + x);}
function SendMsg (Ctrl, PromptStr) { alert (PromptStr)
;
Ctrl.focus(); return;}
</script>
<textarea rows="2" cols="15" name="comments"></textarea><input value="Count Characters" onclick="CheckSize(this.form,1)" type="button" />
<textarea rows="2" cols="15" name="comments"></textarea><input value="Count Characters" onclick="CheckSize(this.form.comments,301)" type="button" />
<textarea rows="2" cols="15" name="special"></textarea><input value="Count Characters" onclick="CheckSize(this.form.special,400)" type="button" />
Looks like I need a bit of a walk through, I'm doing something wrong. I'm pretty sure you want me to put the number of characters
here...... function CheckSize(Ctrl,300) {
and here?...... if ( Ctrl.value.length <300)
What about in these? Anything go here before the x?
SendMsg (Ctrl, "Number of characters is: " + x); else
SendMsg (Ctrl, "Warning! Description Too Long. Number of characters is: " + x);}
Then this in the body.
(this.form.special,400)
Do I need to change anything?
Thank you very much.
<script type="text/javascript">function CheckSize(Ctrl, y )
if ( Ctrl.value.length < y)
SendMsg (Ctrl, "Number of characters is: " + Ctrl.value.length); else
SendMsg (Ctrl, "Warning! Description Too Long. Number of characters is: " + Ctrl.value.length );}
function SendMsg (Ctrl, PromptStr) { alert (PromptStr)
;
Ctrl.focus(); return;}
</script>
Dont replace anything in this script, you only need one copy of script
Length goes into call to CheckSize, 400 in example below
<textarea rows="2" cols="15" name="special"></textarea><input value="Count Characters" onclick="CheckSize(this.form.special,400)" type="button" />
You can have as many textarea as you like, names must be different for each textarea, replace "special" in both places in example above.