Developer Support »

Limiting the length of submitted data  (See more user questions)

Hi .

Thank you for your question.

There isn't that facility in the script but you can add some code to do it.
Add this line of code to the script:

if(isset($_REQUEST['some_form_field']) && strlen($_REQUEST['some_form_field']) > 100){$errors[] = "Field some_form_field is too long. Maximum length 100 characters.";}

Replace the three instances of some_form_field with the name of the field on
your form that you wish to test.

100 is the number of characters permitted in the input string and includes
spaces. Change the value to suit.

There's various places in the script where this code can go but make sure it
goes after $errors = array(); . Probably as well to put it right after it,
like:

$errors = array();

if(isset($_REQUEST['some_form_field']) && strlen($_REQUEST['some_form_field']) > 100){$errors[] = "Field some_form_field is too long. Maximum length 100 characters.";}

Any questions, just let me know.

Best wishes.

Charles Sweeney
https://formtoemail.com
The world's easiest feedback script!

----- Original Message -----
Sent: Monday, January 17, 2011 1:33 PM
Subject: FormToEmail script

> Comments: Hi, Charles,
>
> Do you perhaps have in a newer version a means of limiting the amount of
> text in a form field?
>
> Thanks,