| View previous topic :: View next topic |
| Author |
Message |
pappszaby
Joined: 21 Nov 2005 Posts: 30
|
Posted: Thu Jan 05, 2006 8:29 am Post subject: limiting the characters in the textarea area |
|
|
Hi there!
I would like to limit the number of characters in the textarea area.
What to do? |
|
| Back to top |
|
 |
Fed Site Admin

Joined: 12 Aug 2005 Posts: 176
|
Posted: Thu Jan 05, 2006 11:46 am Post subject: |
|
|
here's a javascript that allows you to count the chars into a text area and display your visitor the remaining ones
put these lines between the <head> and </head> tags of your page
| Code: | <script language="Javascript" type="text/javascript">
function countAreaChars(areaName,counter,limit)
{
if (areaName.value.length>limit)
areaName.value=areaName.value.substring(0,limit);
else
counter.value = limit - areaName.value.length;
}
</script> |
and these into your page body, obviously you have to adjust them so that they fit your form
| Code: | <form name=formName action="myScript.php">
<textarea name=feedback cols=45 rows=6
onKeyDown="countAreaChars(this.form.feedback,this.form.leftChars,400);"
onKeyUp="countAreaChars(this.form.feedback,this.form.leftChars,400);">
</textarea>
<input type=text name=leftChars readonly size=3 maxlength=3 value="400"> chars left
</form> |
I hope it helps 
Last edited by Fed on Mon May 15, 2006 3:59 pm; edited 1 time in total |
|
| Back to top |
|
 |
pappszaby
Joined: 21 Nov 2005 Posts: 30
|
Posted: Fri Jan 06, 2006 12:03 pm Post subject: re |
|
|
Hi Fed! Thanks
It is working properly but now the web mail is not working!
I need this stuff for the same fill out form as it is posted in this forum. I quess you still remember it. It is the next topic in General Help. |
|
| Back to top |
|
 |
Fed Site Admin

Joined: 12 Aug 2005 Posts: 176
|
Posted: Fri Jan 06, 2006 3:08 pm Post subject: |
|
|
well you have to integrate them both
I mean, you don't have to put 2 <form> statements, you need to put only this in your form, where you want the textarea to appear
| Code: | <textarea name=feedback cols=45 rows=6
onKeyDown="countAreaChars(this.form.feedback,this.form.leftChars,400);"
onKeyUp="countAreaChars(this.form.feedback,this.form.leftChars,400);">
</textarea>
<input type=text name=leftChars readonly size=3 maxlength=3 value="400"> chars left |
I hope you understand what I mean (and I hope I understood the reason why it's not working )
Last edited by Fed on Mon May 15, 2006 4:00 pm; edited 1 time in total |
|
| Back to top |
|
 |
pappszaby
Joined: 21 Nov 2005 Posts: 30
|
Posted: Fri Jan 06, 2006 3:53 pm Post subject: |
|
|
OK
Now is working and I understand the reason!
It is not possible 2 forms in the <body>
Thanks again
You were very helpfull.
I might be back for other questions.
 |
|
| Back to top |
|
 |
Fed Site Admin

Joined: 12 Aug 2005 Posts: 176
|
Posted: Fri Jan 06, 2006 4:12 pm Post subject: |
|
|
2 forms in the same body are ok, btw they can't be nested  |
|
| Back to top |
|
 |
pappszaby
Joined: 21 Nov 2005 Posts: 30
|
Posted: Fri Jan 06, 2006 4:17 pm Post subject: |
|
|
I hope that it is does not bother u that I don't know anything about programing. But I never study programing  |
|
| Back to top |
|
 |
Fed Site Admin

Joined: 12 Aug 2005 Posts: 176
|
Posted: Fri Jan 06, 2006 4:23 pm Post subject: |
|
|
no worries, you're welcome
don't miss to help the others when someone needs help...this is what forums are supposed to be used for  |
|
| Back to top |
|
 |
pappszaby
Joined: 21 Nov 2005 Posts: 30
|
Posted: Fri Jan 06, 2006 4:25 pm Post subject: |
|
|
You are right but while youi were off I get on a hungarian forum and they were rude to me the admin told me that I'm not suposed to ask such things
Your forum is much better  |
|
| Back to top |
|
 |
Fed Site Admin

Joined: 12 Aug 2005 Posts: 176
|
Posted: Fri Jan 06, 2006 4:59 pm Post subject: |
|
|
ok because usually you can't go to a forum and say: hello, I need this, can someone make it for me?
you can imagine that this is not the right way, as usually forums are used to clarify little problems while developing something, but until I can and it's a matter of a few lines of code, I like helping the others and I hope you'll do the same when someone needs something you know  |
|
| Back to top |
|
 |
pappszaby
Joined: 21 Nov 2005 Posts: 30
|
Posted: Fri Jan 06, 2006 5:06 pm Post subject: |
|
|
Of corese! I understand! I agree but they were a bit rude thats it.
 |
|
| Back to top |
|
 |
pappszaby
Joined: 21 Nov 2005 Posts: 30
|
Posted: Mon Jan 09, 2006 7:54 am Post subject: |
|
|
Hi Fed!
There is a small problem that I don't know how to correct.
When in the left Chars area the value reaches "0" the mailer.php does not let it go trough because it is set to warn to go back.
For the mailer the "0" value is still an empty value.
So eight er the leftChars area should stop at 1 or the 0 value to be recognize as a value. |
|
| Back to top |
|
 |
Fed Site Admin

Joined: 12 Aug 2005 Posts: 176
|
Posted: Mon Jan 09, 2006 11:23 am Post subject: |
|
|
| what's the exact given error/message? |
|
| Back to top |
|
 |
pappszaby
Joined: 21 Nov 2005 Posts: 30
|
Posted: Mon Jan 09, 2006 11:27 am Post subject: |
|
|
Because the php looks like this !
<?PHP
$to = "you@xyz.com";
$subject = "Order";
$headers = "Order";
$forward = 0;
$location = "";
$date = date ("l, F jS, Y");
$time = date ("h:i A");
$msg = "Message Date: $date Time: $time.\n\n";
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
foreach ($_POST as $key => $value)
{
if (empty($value))
{
echo "Please go back and fill all the required fields.";
Die();
}
$msg .= ucfirst ($key) ." : ". $value . "\n";
}
}
else
{
foreach ($_GET as $key => $value)
{
if (empty($value))
{
echo "Please go back and fill all the required fields.";
Die();
}
$msg .= ucfirst ($key) ." : ". $value . "\n";
}
}
mail($to, $subject, $msg, $headers);
if ($forward == 1) {
header ("Location:$location");
}
else {
echo "Thank you for your order!";
}
?>
It is imposible to enter a single 0 in any filed because that is equal to an empty field. So if the counter reaches 0 than the filed is equal to an empty filed so basically does not let the mail to go trough |
|
| Back to top |
|
 |
pappszaby
Joined: 21 Nov 2005 Posts: 30
|
Posted: Mon Jan 09, 2006 11:57 am Post subject: |
|
|
basically the exact given error massage is the
echo "Please go back and fill all the required fields."; |
|
| Back to top |
|
 |
|