Developer Support »

Displaying the names of required fields in error messages  (See more user questions)

Hi Charles,

Thank you for your prompt reply. That bit of code worked great.

Thank you for your help.

Kind regards,

On 17/11/2010 16:43, FormToEmail.com wrote:
> Hi .
>
> Good to hear from you. Thank you for your question and kind words.
>
> There isn't a facility in the script to display the field names in a
> particular way in the event of a required field not being completed
> but you can edit the code to make it do so.
>
> Locate this line in the script (line 1192 in a stock script, version
> 3.8):
>
> foreach($required_fields as $value){if((!isset($_REQUEST[$value]) ||
> (empty($_REQUEST[$value]) && $_REQUEST[$value] != "0")) &&
> (!isset($_FILES[$value]['name']) ||
> empty($_FILES[$value]['name']))){$errors[] = "Please complete the
> $value field";}}
>
> Replace it with this line:
>
> foreach($required_fields as $value){if((!isset($_REQUEST[$value]) ||
> (empty($_REQUEST[$value]) && $_REQUEST[$value] != "0")) &&
> (!isset($_FILES[$value]['name']) ||
> empty($_FILES[$value]['name']))){$errors[] = "Please complete the
> <span
> style=\"color:#000000\">{$required_fields_display_name[$value]}</span>
> field";}}
>
> ABOVE the newly entered line, add this line:
>
> $required_fields_display_name = array('First_name' => 'First
> name','Last_name' => 'Last name');
>
> Change the line to suit. The keys of the array are your actual field
> names (named exactly as they are in your form). The values are the
> values you would like to be displayed in the event of an error. The
> format is this:
>
> $required_fields_display_name = array('key' => 'value','key' => 'value');
>
> ...or:
>
> $required_fields_display_name = array('field name' => 'display
> name','field name' => 'display name');
>
> Note. You need to have ALL your required fields in the above array.
>
> Best wishes.
>
> Charles Sweeney
> https://formtoemail.com
> The world's easiest feedback script!
>
> ----- Original Message -----
> Sent: Wednesday, November 17, 2010 3:28 PM
> Subject: Re: FormToEmail-Pro
>
>
>> Hi Charles,
>>
>> First I would like to say that I am very pleased with the script. It is
>> very easy to understand, logical and does what I need it to do. Yours is
>> not the first script I have tried, but is one of the easiest to use
>> while still having all the features I needed.
>>
>> I just have a question. I have configured the script to show
>> the error messages on the same page as the form and that is working
>> great, the only problem is that when it displays the errors it says, for
>> example "Please complete the First_name field" is there any way to
>> remove the underscore. I know it is taking my field name but is there
>> some code I can add to remove it?
>>
>> Kind regards,