Support » Plugin: HTML Forms » Custom Validation

  • Resolved jakus


    Hey there,

    Just started using this plugin, the flexibility is great so far!

    I was wondering if you had any recommended methods for implementing custom validation, either client or server side?

    I know native browser validation is included, but I’d like to be able to implement a more uniform style and also potentially stop malicious content being submitted server-side (once client-side validation is cleared).


Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Lap


    We have a huge load of features that we will add in the future, custom validation integration being one on the wishlist as well.

    For now you could go with something like (or any other variant of that), but it’s somewhat unrelated to our plugin at this point.

    Plugin Author Danny van Kooten


    Hey Jakus,

    To add to what my colleague said, here’s what the plugin already does (server-side).

    – It checks for any fields marked as “required” in your form content.
    – It validates all “email” fields.

    You can implement additional validation by hooking into the hf_validate_form filter hook.

    Here’s an example:

    add_filter( 'hf_validate_form', function( $error_code, $form, $data ) {
    	if( $data['SOME_FIELD'] !== 'value we want' ) {
    		$error_code = 'error'; // This shows the general error message right now.
    	return $error_code;
    }, 10, 3 );

    Right now you can return any non-empty string to raise an error.

    Hope that clarifies a little. If you have any ideas on how to further improve upon this, let us know please.

    This is great info! Thanks guys.

    I probably didn’t dig into the documentation as much as I could have.

    I’ll let you know if I think of anything else that could be implemented.


    • This reply was modified 4 months, 1 week ago by  jakus.
    Plugin Author Danny van Kooten


    Hey Jakus,

    No worries, the knowledge base is still pretty new so definitely lots of room to improve there for us. I just added an article on custom form validation to it.


Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.