contra10 Posted January 27, 2009 Share Posted January 27, 2009 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>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/142686-limit-in-text-area/ Share on other sites More sharing options...
kodosai Posted January 27, 2009 Share Posted January 27, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/142686-limit-in-text-area/#findComment-747965 Share on other sites More sharing options...
sdi126 Posted January 27, 2009 Share Posted January 27, 2009 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>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/142686-limit-in-text-area/#findComment-747966 Share on other sites More sharing options...
contra10 Posted January 27, 2009 Author Share Posted January 27, 2009 still working on the javascript...but the 30px...didn;t word for me....regardless as to wheter i put it in the td or table tags Quote Link to comment https://forums.phpfreaks.com/topic/142686-limit-in-text-area/#findComment-748012 Share on other sites More sharing options...
aznkidzx Posted January 27, 2009 Share Posted January 27, 2009 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> Quote Link to comment https://forums.phpfreaks.com/topic/142686-limit-in-text-area/#findComment-748041 Share on other sites More sharing options...
contra10 Posted January 27, 2009 Author Share Posted January 27, 2009 thank you Quote Link to comment https://forums.phpfreaks.com/topic/142686-limit-in-text-area/#findComment-748053 Share on other sites More sharing options...
haku Posted January 28, 2009 Share Posted January 28, 2009 aznkid: center tags are deprecated, so you should stop using them. You are just spreading bad practice to newbies. Quote Link to comment https://forums.phpfreaks.com/topic/142686-limit-in-text-area/#findComment-748170 Share on other sites More sharing options...
aznkidzx Posted January 28, 2009 Share Posted January 28, 2009 aznkid: center tags are deprecated, so you should stop using them. You are just spreading bad practice to newbies. Oh how about <align="center">? Quote Link to comment https://forums.phpfreaks.com/topic/142686-limit-in-text-area/#findComment-748176 Share on other sites More sharing options...
haku Posted January 28, 2009 Share Posted January 28, 2009 align tag is also deprecated. It's done in CSS now. text-align: center; or margin: 0 auto; depending on what you are centering. Quote Link to comment https://forums.phpfreaks.com/topic/142686-limit-in-text-area/#findComment-748211 Share on other sites More sharing options...
TheFilmGod Posted January 28, 2009 Share Posted January 28, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/142686-limit-in-text-area/#findComment-748225 Share on other sites More sharing options...
contra10 Posted January 28, 2009 Author Share Posted January 28, 2009 illl use magin: 0 Quote Link to comment https://forums.phpfreaks.com/topic/142686-limit-in-text-area/#findComment-748893 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.