PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Custom Validation by field

  1. I have a form that will eventually be a user registration form that has a custom validation check for a registration code held in the database, but I can't even get the most basic validation check to work. I think must be doing something really simple wrong but I can't tell. I'm using the exact same code in the documentation for get_field_validation, but with my own form and field ID.

    add_filter("gform_field_validation_1_4", "custom_validation", 10, 4);
    function custom_validation($result, $value, $form, $field){
    
        if($result["is_valid"] && intval($value) > 10){
            $result["is_valid"] = false;
            $result["message"] = "Please enter a value less than 10";
        }
        return $result;
    }

    All I wanted to do was make sure I could have custom validation work but not even this works, the form submits successfully no matter what. Does the validation only work on certain field types? I'm using a Single Line Text field. The test form is currently at http://qrkeycard.com/?page_id=5 if you want to see it or try it for yourself.

    Hopefully this is just a facepalm moment and I can feel dumb and then we can laugh and move on.

    Thanks!

    Posted 12 years ago on Saturday September 17, 2011 | Permalink
  2. So this morning I realized that version 1.6 of gravity forms (which the field validation is new in) is still in beta and I'm on 1.5.2.8. So that's why the custom field validation doesn't work. Guess I'll either go beta or use the whole field validation.

    Is there anything in particular that is unstable in the beta? All I'm using it for is one user registration form with a custom validation on one field.

    Posted 12 years ago on Saturday September 17, 2011 | Permalink
  3. There is nothing in particular unstable. There have been little bug fixes, but in my testing it's completely usable. The beta 3 version was just released and it's very stable. Please test it out and see if it meets your needs.

    Posted 12 years ago on Saturday September 17, 2011 | Permalink
  4. I downloaded it and everything seems to be working great, thanks! Now if only I could get my wordpress SQL stuff right... but that's another topic. Thanks again.

    Posted 12 years ago on Saturday September 17, 2011 | Permalink

This topic has been resolved and has been closed to new replies.