Jump to content

Recommended Posts

i'm trying to limit the amount of characters entered in text area

but it won't limit

 

<textarea name="description" type="description" cols="50" rows="7" maxlength="10" STYLE="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #72A4D2;"></textarea>

 

at the same time...i also want to show the information that is entered into mysql using php...it shows but in a straight line...how can i use html to limit the amunt of words in a row

 

<?php
echo "<tr><td height='200' valign='top' align='left'>$evdescription</td></tr>";
?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/142686-limit-in-text-area/
Share on other sites

there is no imposed limitation attribute on the <textarea> tag. Only on the <input type=text> will that limitation work.

 

Although I did find this option available, but only with the use of javascript.

http://javascript.internet.com/forms/limit-textarea.html

 

Not a very good solution with the amount of people that turn js off these days.

 

Still though, My recommendation would be to do a javascript counter maybe as just a way of notifying the user they have "x" characters left, and that the form handler will truncate anything larger than X characters when submitted.

Link to comment
https://forums.phpfreaks.com/topic/142686-limit-in-text-area/#findComment-747965
Share on other sites

For question # 1...look at http://www.insidedhtml.com/ie5/htc/ts08/page1.asp

 

For question # 2...this could be limited by setting the width property on the td element

such as

<?php
echo "<tr><td height='200' valign='top' align='left' width='30px'>$evdescription</td></tr>";
?>

Link to comment
https://forums.phpfreaks.com/topic/142686-limit-in-text-area/#findComment-747966
Share on other sites

Place between <head> and </head>

 

<!-- Begin
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}
// End -->
</script>

 

Place in <body>

 


<!-- textCounter() parameters are:  text field, the count field, max length -->

<center>
<form name=myform action="YOUR-SCRIPT.CGI">
<font size="1" face="arial, helvetica, sans-serif"> ( You may enter up to 125 characters. )<br> //change 125
<textarea name=message wrap=physical cols=28 rows=4 onKeyDown="textCounter(this.form.message,this.form.remLen,125);" // change 125 to anything you wish
onKeyUp="textCounter(this.form.message,this.form.remLen,125);"></textarea> // change to same as abovce
<br>
<input readonly type=text name=remLen size=3 maxlength=3 value="125"> characters left</font> // change 125
</form>
</center>

Link to comment
https://forums.phpfreaks.com/topic/142686-limit-in-text-area/#findComment-748041
Share on other sites

I'm sorry but this incorrect/deprecated centering is my little pet peeve...

 

Don't use html to center contents because it adds additionally markup, when css can do the same thing. Additional markup creates a bigger headache for php developing. The less code you need to dynamically create, the better.

 

text-align: center; should only be used for inline TEXT. Margin: 0 auto; is a good way to center any fixed width block elment, such as a div or pargraph.

Link to comment
https://forums.phpfreaks.com/topic/142686-limit-in-text-area/#findComment-748225
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.