SMS Contact form - limit characters to 140

©

©®

I am wanting to have a contact form on my website so friends can email
me. This si working great and I receive their comments.
I thought it would be a great idea to add the ability that they could
send me a text message as well, but realised I would need to limit the
text input to about 140 characters.
Does anyone have a tutorial on how I could do this please? I would like
to be able to decide what the total character limit is e.g. 140 or 200
or whatever I choose.
Thanks very much.
PS - Having a counter show in real-time how many characters are
available to type would be very helpful.
 
©

©®

Just to add, the message would be sent via email (not an SMS gateway) to
an ATT phone so the message would get sent to (e-mail address removed)

It is the showing how many characters and limiting the characters that I
need help on how to do it.
 
J

J.O. Aho

Jerry said:
Just use strlen() to determine the length; if it's over the limit,
redisplay the form with an error message (and the original text).

You can also limit it client-side - but that's a javascript problem.

and of course, doing the check only client side is a bad way to do things.


In case the OP did miss, SMS are sent in multiples of 160 characters, so a
limit of 140 or 200 as in the original post is a waste of money, it's better
to use the message fully.
 
H

Harlan Messinger

©® said:
I am wanting to have a contact form on my website so friends can email
me. This si working great and I receive their comments.
I thought it would be a great idea to add the ability that they could
send me a text message as well, but realised I would need to limit the
text input to about 140 characters.
Does anyone have a tutorial on how I could do this please? I would like
to be able to decide what the total character limit is e.g. 140 or 200
or whatever I choose.
Thanks very much.
PS - Having a counter show in real-time how many characters are
available to type would be very helpful.
<input type="text" maxlength="140" ...>
 
J

Jonathan N. Little

©® said:
I am wanting to have a contact form on my website so friends can email
me. This si working great and I receive their comments.
I thought it would be a great idea to add the ability that they could
send me a text message as well, but realised I would need to limit the
text input to about 140 characters.
Does anyone have a tutorial on how I could do this please? I would like
to be able to decide what the total character limit is e.g. 140 or 200
or whatever I choose.

On the server size have the script, I am assuming PHP since you have
alt.php included, limit the posted input to 'n' characters...

$limit = 200; //set to whatever you want to limit the string to...
// be sure to filter, NEVER trust user input!
$message = (YourFunctionToSanitizeInput($_POST['message']), 0, $limit);

PS - Having a counter show in real-time how many characters are
available to type would be very helpful.

Of course it will only work with JavaScript enabled, but not to hard to
attached a JS function to onkeyup of the textarea that counts the
content characters then updates a text node with the results.
 
©

©®

In case the OP did miss, SMS are sent in multiples of 160 characters,
so a
limit of 140 or 200 as in the original post is a waste of money, it's
better
to use the message fully.

Yeah - I did know that, but just chose 140 and 200 as ewxamples. I
thought that if it is 140, then any name, subjects etc. might make up
the 160.

I am a total newbie so will have to search out an example as I don't
know how to program php yet.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,017
Latest member
GreenAcreCBDGummiesReview

Latest Threads

Top