Limit Characters in a TextArea

This will limit the number of characters a user types in a textarea.


<HTML>

<HEAD>
<META NAME="GENERATOR" CONTENT="snap6 - Html questionnaire export">
<META NAME="ROBOTS" CONTENT="NOINDEX">
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>Test - What happens when max field length is exceeded?</TITLE>
<script language="javascript">
<!--


function checkchars(cur){
//change max length to determine below
var maxlength=5
var mymessageA="Too much data in the text box! Please remove "
var mymessageB=" characters"
if (cur.V2.value.length>maxlength){
alert(' '+ mymessageA + ' ' +
(cur.V2.value.length - maxlength)+ ' ' + mymessageB + ' ')
return false
}

if (cur.V4.value.length>maxlength){
alert(' '+ mymessageA + ' ' +
(cur.V4.value.length - maxlength)+ ' ' + mymessageB + ' ')
return false
}

}
//-->
</script>
</HEAD>
<BODY TOPMARGIN=0 BGCOLOR = "#FFFFFF" BACKGROUND="*">
<FORM ACTION="http://www.mercator.co.uk/cgi-bin/subques.pl" METHOD=POST onsubmit="return checkchars(this)">
<INPUT TYPE=HIDDEN NAME=":SURVEY:" VALUE="open_test1">
<INPUT TYPE=HIDDEN NAME=":EMAIL:" VALUE="clayton@src.org">
<INPUT TYPE=HIDDEN NAME=":USERID:" VALUE="51468S/999">


<TABLE BORDER="0" CELLSPACING="0" SUMMARY="Page Columns" WIDTH="100%">
<TR>
<TD COLSPAN="3" WIDTH="100%" ALIGN="LEFT" VALIGN="TOP">
<TABLE BORDER="0" CELLSPACING="0" SUMMARY="Question" WIDTH="100%">
<TR>
<TD>
 </TD>
</TR>
</TABLE>
<TABLE BORDER="0" CELLSPACING="0" SUMMARY="Question" WIDTH="100%">
<TR>
<TD WIDTH="100%" ALIGN="CENTER" VALIGN="TOP">
<FONT SIZE="6" COLOR="#000000" FACE="Arial"><B>
Open Ended Question Test - What happens when a response exceeds max field length?</B></FONT>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD WIDTH="46%" ALIGN="LEFT" VALIGN="TOP">
<TABLE BORDER="0" CELLSPACING="0" SUMMARY="Question" WIDTH="100%">
<TR>
<TD COLSPAN="3">
 </TD>
</TR>
</TABLE>
<TABLE BORDER="0" CELLSPACING="0" SUMMARY="Question" WIDTH="100%">
<TR>
<TD ROWSPAN="2" WIDTH="10%" ALIGN="LEFT" VALIGN="TOP">
<a name="Q1">
<FONT SIZE="2" COLOR="#000000" FACE="Arial"><B>
Q1</B></FONT>
</a></TD>
<TD COLSPAN="2" WIDTH="90%" ALIGN="LEFT" VALIGN="TOP">
<FONT SIZE="2" COLOR="#000000" FACE="Arial"><B>
First Open Ended Question - Exceed field length</B></FONT>
</TD>
</TR>
<TR>
<TD WIDTH="90%" ALIGN="RIGHT" VALIGN="BOTTOM">






<textarea rows="40" cols="25" name="V2"></textarea></TD>
</TR>
</TABLE>
<TABLE BORDER="0" CELLSPACING="0" SUMMARY="Question" WIDTH="100%">
<TR>
<TD COLSPAN="4">
 </TD>
</TR>
</TABLE>
<TABLE BORDER="0" CELLSPACING="0" SUMMARY="Question" WIDTH="100%">
<TR>
<TD ROWSPAN="4" WIDTH="10%" ALIGN="LEFT" VALIGN="TOP">
<a name="Q2">
<FONT SIZE="2" COLOR="#000000" FACE="Arial"><B>
Q2</B></FONT>
</a></TD>
<TD COLSPAN="3" WIDTH="90%" ALIGN="LEFT" VALIGN="TOP">
<FONT SIZE="2" COLOR="#000000" FACE="Arial"><B>
First Mult Choice Question </B></FONT>
</TD>
</TR>
<TR>
<TD ROWSPAN="3" WIDTH="5%">
 </TD>
<TD WIDTH="85%" ALIGN="LEFT" VALIGN="BOTTOM">
<TABLE BORDER="0" CELLSPACING="0" SUMMARY="Code" WIDTH="100%">
<TR>
<TD WIDTH="94%" ALIGN="LEFT" VALIGN="TOP">
<FONT SIZE="2" COLOR="#000000" FACE="Arial"><I>
Poor</I></FONT>
</TD>
<TD WIDTH="6%" ALIGN="RIGHT" VALIGN="BOTTOM">
<input type=checkbox value="1" name="V3"></TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD WIDTH="85%" ALIGN="LEFT" VALIGN="BOTTOM">
<TABLE BORDER="0" CELLSPACING="0" SUMMARY="Code" WIDTH="100%">
<TR>
<TD WIDTH="94%" ALIGN="LEFT" VALIGN="TOP">
<FONT SIZE="2" COLOR="#000000" FACE="Arial"><I>
Good</I></FONT>
</TD>
<TD WIDTH="6%" ALIGN="RIGHT" VALIGN="BOTTOM">
<input type=checkbox value="2" name="V3"></TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD WIDTH="85%" ALIGN="LEFT" VALIGN="BOTTOM">
<TABLE BORDER="0" CELLSPACING="0" SUMMARY="Code" WIDTH="100%">
<TR>
<TD WIDTH="94%" ALIGN="LEFT" VALIGN="TOP">
<FONT SIZE="2" COLOR="#000000" FACE="Arial"><I>
Excellent</I></FONT>
</TD>
<TD WIDTH="6%" ALIGN="RIGHT" VALIGN="BOTTOM">
<input type=checkbox value="3" name="V3"></TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</TD>
<TD WIDTH="7%">
 </TD>
<TD WIDTH="46%" ALIGN="LEFT" VALIGN="TOP">
<TABLE BORDER="0" CELLSPACING="0" SUMMARY="Question" WIDTH="100%">
<TR>
<TD COLSPAN="3">
 </TD>
</TR>
</TABLE>
<TABLE BORDER="0" CELLSPACING="0" SUMMARY="Question" WIDTH="100%">
<TR>
<TD ROWSPAN="2" WIDTH="10%" ALIGN="LEFT" VALIGN="TOP">
<a name="Q3">
<FONT SIZE="2" COLOR="#000000" FACE="Arial"><B>
Q3</B></FONT>
</a></TD>
<TD COLSPAN="2" WIDTH="90%" ALIGN="LEFT" VALIGN="TOP">
<FONT SIZE="2" COLOR="#000000" FACE="Arial"><B>
Second Open Ended Question- Within field length </B></FONT>
</TD>
</TR>
<TR>
<TD WIDTH="90%" ALIGN="RIGHT" VALIGN="BOTTOM">


<textarea rows="40" cols="25" name="V4"></textarea></TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>


<BR>


<DIV align=center><!--inlcudes div-->

<INPUT type=reset value="Reset">
<INPUT type=submit value="Submit">
</DIV>
<DIV align=center><IMG VSPACE=4 SRC="pbred12.gif"></DIV>
<BR>
</FORM>
</BODY>
</HTML>

<HTML>

<HEAD>
<META NAME="GENERATOR" CONTENT="snap6 - Html questionnaire export">
<META NAME="ROBOTS" CONTENT="NOINDEX">
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>Test - What happens when max field length is exceeded?</TITLE>
<script language="javascript">
<!--


function checkchars(cur){
//change max length to determine below
var maxlength=5
var mymessageA="Too much data in the text box! Please remove "
var mymessageB=" characters"
if (cur.V2.value.length>maxlength){
alert(' '+ mymessageA + ' ' +
(cur.V2.value.length - maxlength)+ ' ' + mymessageB + ' ')
return false
}

if (cur.V4.value.length>maxlength){
alert(' '+ mymessageA + ' ' +
(cur.V4.value.length - maxlength)+ ' ' + mymessageB + ' ')
return false
}

}
//-->
</script>
</HEAD>
<BODY TOPMARGIN=0 BGCOLOR = "#FFFFFF" BACKGROUND="*">
<FORM ACTION="http://www.mercator.co.uk/cgi-bin/subques.pl" METHOD=POST onsubmit="return checkchars(this)">
<INPUT TYPE=HIDDEN NAME=":SURVEY:" VALUE="open_test1">
<INPUT TYPE=HIDDEN NAME=":EMAIL:" VALUE="clayton@src.org">
<INPUT TYPE=HIDDEN NAME=":USERID:" VALUE="51468S/999">


<TABLE BORDER="0" CELLSPACING="0" SUMMARY="Page Columns" WIDTH="100%">
<TR>
<TD COLSPAN="3" WIDTH="100%" ALIGN="LEFT" VALIGN="TOP">
<TABLE BORDER="0" CELLSPACING="0" SUMMARY="Question" WIDTH="100%">
<TR>
<TD>
 </TD>
</TR>
</TABLE>
<TABLE BORDER="0" CELLSPACING="0" SUMMARY="Question" WIDTH="100%">
<TR>
<TD WIDTH="100%" ALIGN="CENTER" VALIGN="TOP">
<FONT SIZE="6" COLOR="#000000" FACE="Arial"><B>
Open Ended Question Test - What happens when a response exceeds max field length?</B></FONT>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD WIDTH="46%" ALIGN="LEFT" VALIGN="TOP">
<TABLE BORDER="0" CELLSPACING="0" SUMMARY="Question" WIDTH="100%">
<TR>
<TD COLSPAN="3">
 </TD>
</TR>
</TABLE>
<TABLE BORDER="0" CELLSPACING="0" SUMMARY="Question" WIDTH="100%">
<TR>
<TD ROWSPAN="2" WIDTH="10%" ALIGN="LEFT" VALIGN="TOP">
<a name="Q1">
<FONT SIZE="2" COLOR="#000000" FACE="Arial"><B>
Q1</B></FONT>
</a></TD>
<TD COLSPAN="2" WIDTH="90%" ALIGN="LEFT" VALIGN="TOP">
<FONT SIZE="2" COLOR="#000000" FACE="Arial"><B>
First Open Ended Question - Exceed field length</B></FONT>
</TD>
</TR>
<TR>
<TD WIDTH="90%" ALIGN="RIGHT" VALIGN="BOTTOM">






<textarea rows="40" cols="25" name="V2"></textarea></TD>
</TR>
</TABLE>
<TABLE BORDER="0" CELLSPACING="0" SUMMARY="Question" WIDTH="100%">
<TR>
<TD COLSPAN="4">
 </TD>
</TR>
</TABLE>
<TABLE BORDER="0" CELLSPACING="0" SUMMARY="Question" WIDTH="100%">
<TR>
<TD ROWSPAN="4" WIDTH="10%" ALIGN="LEFT" VALIGN="TOP">
<a name="Q2">
<FONT SIZE="2" COLOR="#000000" FACE="Arial"><B>
Q2</B></FONT>
</a></TD>
<TD COLSPAN="3" WIDTH="90%" ALIGN="LEFT" VALIGN="TOP">
<FONT SIZE="2" COLOR="#000000" FACE="Arial"><B>
First Mult Choice Question </B></FONT>
</TD>
</TR>
<TR>
<TD ROWSPAN="3" WIDTH="5%">
 </TD>
<TD WIDTH="85%" ALIGN="LEFT" VALIGN="BOTTOM">
<TABLE BORDER="0" CELLSPACING="0" SUMMARY="Code" WIDTH="100%">
<TR>
<TD WIDTH="94%" ALIGN="LEFT" VALIGN="TOP">
<FONT SIZE="2" COLOR="#000000" FACE="Arial"><I>
Poor</I></FONT>
</TD>
<TD WIDTH="6%" ALIGN="RIGHT" VALIGN="BOTTOM">
<input type=checkbox value="1" name="V3"></TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD WIDTH="85%" ALIGN="LEFT" VALIGN="BOTTOM">
<TABLE BORDER="0" CELLSPACING="0" SUMMARY="Code" WIDTH="100%">
<TR>
<TD WIDTH="94%" ALIGN="LEFT" VALIGN="TOP">
<FONT SIZE="2" COLOR="#000000" FACE="Arial"><I>
Good</I></FONT>
</TD>
<TD WIDTH="6%" ALIGN="RIGHT" VALIGN="BOTTOM">
<input type=checkbox value="2" name="V3"></TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD WIDTH="85%" ALIGN="LEFT" VALIGN="BOTTOM">
<TABLE BORDER="0" CELLSPACING="0" SUMMARY="Code" WIDTH="100%">
<TR>
<TD WIDTH="94%" ALIGN="LEFT" VALIGN="TOP">
<FONT SIZE="2" COLOR="#000000" FACE="Arial"><I>
Excellent</I></FONT>
</TD>
<TD WIDTH="6%" ALIGN="RIGHT" VALIGN="BOTTOM">
<input type=checkbox value="3" name="V3"></TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</TD>
<TD WIDTH="7%">
 </TD>
<TD WIDTH="46%" ALIGN="LEFT" VALIGN="TOP">
<TABLE BORDER="0" CELLSPACING="0" SUMMARY="Question" WIDTH="100%">
<TR>
<TD COLSPAN="3">
 </TD>
</TR>
</TABLE>
<TABLE BORDER="0" CELLSPACING="0" SUMMARY="Question" WIDTH="100%">
<TR>
<TD ROWSPAN="2" WIDTH="10%" ALIGN="LEFT" VALIGN="TOP">
<a name="Q3">
<FONT SIZE="2" COLOR="#000000" FACE="Arial"><B>
Q3</B></FONT>
</a></TD>
<TD COLSPAN="2" WIDTH="90%" ALIGN="LEFT" VALIGN="TOP">
<FONT SIZE="2" COLOR="#000000" FACE="Arial"><B>
Second Open Ended Question- Within field length </B></FONT>
</TD>
</TR>
<TR>
<TD WIDTH="90%" ALIGN="RIGHT" VALIGN="BOTTOM">


<textarea rows="40" cols="25" name="V4"></textarea></TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>


<BR>


<DIV align=center><!--inlcudes div-->

<INPUT type=reset value="Reset">
<INPUT type=submit value="Submit">
</DIV>
<DIV align=center><IMG VSPACE=4 SRC="pbred12.gif"></DIV>
<BR>
</FORM>
</BODY>
</HTML>

Views 366 Downloads 151

''

JeffSmith
26
Components JS+JQuery
Revisions

v1.0