• Resolved nadyusha

    (@nadyusha)


    I have a problem creating custom validation for my Ninja Forms. I am using something like this:

    add_filter('ninja_forms_submit_data', 'custom_ninja_forms_submit_data');
    function custom_ninja_forms_submit_data($form_data)
    {
    $field_id = 2;
    $field_value = $form_data['fields'][$field_id]['value'];
    
    $exists = true; // Check your database if $field_value exists
    
    if($exists)
    {
        $form_data['errors']['fields'][$field_id] = 'Value already exists';
    }
    
    return $form_data;
    }

    the problem is – my validation isn’t related to fields. I check some of the entered data and in case of an error – I need to show just general error message without blocking submit button. This code above shows error message below the field 2 and user can’t submit the form again without editing this field.

Viewing 1 replies (of 1 total)
  • Plugin Support Curtis

    (@curtisbrownlee)

    Hello,

    Thank you for contacting us. I hope that you are doing well.

    For custom code, there is developer documentation which is provided as-is and also a Developer Slack channel where coders can give advice on how to achieve custom code goals:
    Codex: https://developer.ninjaforms.com/codex/
    Slack channel: https://developer.ninjaforms.com/slack

    The developers of Ninja Forms also frequent the Development Slack channel.

    Because we only check these forums once per week, we strongly encourage you to reach out to us here with any followup questions in order to get a timely response: https://ninjaforms.com/contact/ There, we offer support free support directly to our Ninja Forms users with significantly more privacy and a faster response time.

    Best regards,

    Curtis
    WP Ninja

Viewing 1 replies (of 1 total)
  • The topic ‘Ninja Forms Custom Validation’ is closed to new replies.