Name/email signup validation messages don't change

There are currently 2 issues on this simple 2 field signup form.

  1. first and last are required. < that’s all it needs to say … currently the error reads >> This field is required. Please complete the following fields: first name, last name.

I have tried numerous ways to change that default gf text and it won’t take. I have also added a custom message in GF for the name field and it just adds it to it’s default. That’s issue one… get rid of the gf message mentioning fields all together and simply say ‘first and last are required’ < one line no breaks.

  1. The validation error message for the email field was also too long and makes no sense to people… The wizards at Gravity Perks (matt) helped out fixing that to say just ‘Already Signed Up’ and that’s great… but there was also a validation message box I had displaying and that no longer displays after the code change. I was hoping to keep that message box for the email inputs only as it is already removed for the name inputs. This is a screenshot of what I am trying to do ..

Here is another view …

That second screenshot … the lengthy text under the email inputs, the GF default is now replaced with wizard Matts help to read just ‘Already Signed Up’ ..

But, now the pink box with more instructions no longer displays. That is the validation container and message for that field. The code is getting wacky here but this is what the functions currently look like >>

/* Sign Up Form Validation errors */

add_filter( ‘gform_validation_message’, function ( $message, $form ) {
if ( gf_upgrade()->get_submissions_block() ) {
return $message;
}

$name_error = false;
$email_error = false;
$duplicate_email = false;

foreach ( $form['fields'] as $field ) {
    if ( $field->failed_validation ) {
        // Check for name field error (field ID 5)
        if ( $field->id == 5 ) {
            $name_error = true;
        }

        // Check for email field error (field ID 6)
        if ( $field->id == 6 ) {
            if ( strpos( $field->validation_message, 'already' ) !== false ) {
                $duplicate_email = true;
            } else {
                $email_error = true;
            }
        }
    }
}

if ( $name_error ) {
$message = “”;
}
elseif ( $email_error ) {
$message = “”;
}
elseif ( $duplicate_email ) {
$message = “The email address you entered already exists in The Kro list. If you have not received The Kro or need assistance removing or updating the email address in question, contact: signup@akroagatemarbles.com.”;
}

return $message;

}, 10, 2 );

// Gravity Perks // Remove empty box from name field validation on form 2
add_filter( ‘gform_form_validation_errors_markup_2’, function ( $markup, $form ) {

if( ! strpos( $markup, '<p>' ) ){
	$markup = '';
}

return $markup;

}, 10, 2 );

// Gravity Perks // already subscribed error message
add_filter( ‘gform_duplicate_message_2’, function ( $message, $form, $field ) {

if( $field->id == 6 ){
	return 'Already Signed Up';
}

return $message;

}, 10, 3 );

$message is no longer displaying and I was hoping to keep that container as I can add html links or whatever to it with clearer instructions that the validation error message which is kind of above many peoples thinking. The live form is here> The History of Akro Agate Marbles • Reference You can skip the name inputs and everything to see the validation errors or add your first name and 2 different email addresses (mismatched.. etcetera) to check it out. I might just have to forget about the $message formatted in the box but really want to change that horrendous line breaking error validation text to be very simple… First and Last required. That’s it. Any thoughts? I’m done searching for a solution to that.

AS far as the email already exists message in the pink box frame… I tried to add it to the new function in $message and a couple places , but it is not taking. I does display if I forgo this shorter input error message and leave the longer gf default message, but I don’t want to do that.

// Gravity Perks // already subscribed error message
add_filter( ‘gform_duplicate_message_2’, function ( $message, $form, $field ) {

if( $field->id == 6 ){
	return 'Already Signed Up';
}

return $message;

}, 10, 3 );

Any advice is appreciated. I am not a coder. I am a writer, photographer, designer and I patchworked together what I have in the past year learning divi and css etcetera with help from people like you. I just finished 2 sales gravity forms that took 2 months to get right and work with paypal checkout and shipstation for sales at the end of the year if I can get the book done. I appreciate you all. I hope someone has a solution.

Thanks for your help.
-Tom

ps the spinner is working… took 2 weeks. lol.

here is a visual that will help make more sense of what I am trying to accomplish.

The second issue of the validation message box not displaying is solved. Alignments and css are all complete, The problem is the default name field validation message… How can it be changed from the default gravity form message that is TOO LONG and line breaks multiple times. Anyone?

Hi,

Glad you’ve been able to make some progress with the issues you were having.

In regard to the other issue, the code below should work to change the required validation message on the Name field.

add_filter( 'gform_field_validation', function( $result, $value, $form, $field ) {

    // Change '5' to match your Name field ID
    if ( $field->id == 5 && $field->type == 'name' ) {

        $first = rgar( $value, '5.3' );
        $last  = rgar( $value, '5.6' );

        // If either first or last name is blank
        if ( $field->isRequired && ( rgblank( $first ) || rgblank( $last ) ) ) {
            $result['is_valid'] = false;
            $result['message']  = 'First and Last are required.';
        }
    }

    return $result;
}, 10, 4 );

I hope this helps.

Best,