Posts Tagged Text Area
” Text Area With Status – Keep a count of characters left or entered “
the name for the javascript file i am using is limit_chars ,keep the below script in the limit-chars.js file in public folder
<script>
function limit_chars(textarea, limit, info, msg) {
if (!msg) msg = ‘%d characters left.’
var text = textarea.value
var textlength = text.length
if (textlength > limit) {
info.innerHTML = ‘You cannot write more then ‘ + limit + ‘ characters!’
textarea.value = text.substr(0,limit)
return false
} else {
info.innerHTML = msg.sub(‘%d’, limit – textlength)
return true
}
}
</script>
VIEW ::
<textarea cols=”75″ id=”response” name=”response” rows=”2″
onkeyup =”limit_chars(this, limit,
$(‘div/span id’))”></textarea>
<tr>
<td width=100>
Response:
</td>
<td width=440>
<textarea cols=”75″ id=”response” name=”response” rows=”2″ onkeyup =”limit_chars(this, 150, $(‘text_count_display_response’))”></textarea>
</td>
<td width=110>
<div id=”text_count_display_response” ></div>
</td>
</tr>
Dont forget to include the javascript in layouts or the template itself .
Powered by ScribeFire.
Add comment December 24, 2007
” Jumping tabs in text fields depending upon maximum length for the text area/field”
This is the code , follow the steps
<!– Paste the JavaScript code between the HEAD Tags –>
<HEAD>
<SCRIPT LANGUAGE=”javascript”>
<!– This code makes the jump from textbox one to textbox two –>
function check()
{
var letters = document.joe.burns.value.length +1;
if (letters <= 4)
{document.joe.burns.focus()}
else
{document.joe.tammy.focus()}
}
<!– This code makes the jump from textbox two to text box three –>
function check2()
{
var letters2 = document.joe.tammy.value.length +1;
if (letters2 <= 4)
{document.joe.tammy.focus()}
else
{document.joe.chloe.focus()}
}
<!– This code makes the jump from textbox three to textbox four –>
function check3()
{
var letters3 = document.joe.chloe.value.length +1;
if (letters3 <= 4)
{document.joe.chloe.focus()}
else
{document.joe.mardi.focus()}
}
<!– This code makes the jump from textbox four to the submit button –>
function check4()
{
var letters4 = document.joe.mardi.value.length +1;
if (letters4 <= 4)
{document.joe.mardi.focus()}
else
{document.joe.go.focus()}
}
</SCRIPT>
</HEAD>
<!– The onLoad in the BODY tag puts focus in the first textbox –>
<BODY BGCOLOR=”ffffff” onLoad=”document.joe.burns.focus()”>
<!– This is the form –>
<FORM NAME=”joe”>
<INPUT TYPE=”text” name=”burns” size=”10″ MAXLENGTH=”4″ onKeyUp=”check()”><BR>
<INPUT TYPE=”text” name=”tammy” size=”10″ MAXLENGTH=”4″ onKeyUp=”check2()”><BR>
<INPUT TYPE=”text” name=”chloe” size=”10″ MAXLENGTH=”4″ onKeyUp=”check3()”><BR>
<INPUT TYPE=”text” name=”mardi” size=”10″ MAXLENGTH=”4″ onKeyUp=”check4()”><BR>
<INPUT TYPE=”submit” VALUE=”Click to Send” NAME=”go”>
</FORM>
Powered by ScribeFire.
Add comment December 24, 2007