Summer Sale: Save 20% on any WS Form edition CODE: SUMMER20 View Pricing

Add Custom Server-Side Validation to Forms in WordPress

Validate submissions and fields server-side, then show feedback, messages, or redirects when checks fail.

  • Validate each field Use server-side validation for individual fields when a form is submitted.
  • Validate full submissions Run validation against the whole submission before processing continues.
  • Show field feedback Return standard or custom invalid feedback underneath a field.
  • Display form messages Show messages before or after the form when validation fails.
  • Redirect on errors Send users to a different URL in the event of an error.
  • Check email addresses Validate email addresses before sending emails with the Send Email action.

WS Form includes server-side validation hooks for validating a full submission or validating each field when a form is submitted. This gives you a way to add your own validation logic to forms in WordPress and return errors back to the form.

Field-level validation can return standard invalid feedback, custom invalid feedback, messages, or a redirect. Submission-level validation can return messages or a redirect. WS Form supports one or more errors by pushing actions to the validation array and returning them to the form.

Validation hooks receive context such as the post mode and a partial submit object. Field validation also includes the field ID, submitted value, and repeatable section row index, and email addresses can be validated before sending emails with the Send Email action.

  • Field-level control

    The field validation hook runs for each field when a form is submitted, so you can apply validation to specific field IDs.

  • Submission-wide checks

    The submission validation hook validates the form submission as a whole and can return form messages or a redirect.

  • Standard invalid feedback

    Return a boolean false value to show the standard invalid feedback message on a field.

  • Custom field messages

    Return your own invalid feedback text for a field, including an array-based field_invalid_feedback action.

  • Flexible form messaging

    Validation messages can appear before or after the form and support message types including success, information, warning, danger, and none.

  • Message display options

    Message actions support options such as clearing other messages, scrolling to the top, setting an offset or duration, and hiding the form.

  • Repeatable section awareness

    Field validation receives the repeatable section row index, which can be used when validating fields inside repeatable sections.

  • Email validation hook

    The email validation filter lets you invalidate an email address before sending emails with the Send Email action.

Real Customer Reviews

Trusted by thousands of WordPress professionals.

  • What a great plugin and framework. There’s also great support from Mark, who really takes care of everything and always has a solution up his sleeve.

    medienstuermer
  • The best plugin and with the best support. We are very happy with WS Forms.

    cfonate
  • I’m not a developer, but if you want to see what a non-techie like me can do with WS Form, I am delighted!

    pedroarturonatan

Frequently Asked Questions

Can WS Form validate individual fields on the server side?

Yes. The wsf_submit_field_validate filter hook is used to validate each field when a form is submitted.

Can WS Form validate an entire submission on the server side?

Yes. The wsf_submit_validate filter hook is used to validate a form submission.

How do I return validation errors to the form?

Validation errors are added by pushing elements to the field error action array and returning that array to WS Form when your hook function ends.

What kinds of validation feedback can be shown?

Field-level validation can show field invalid feedback, messages, and redirects. Submission-level validation can show messages and redirects.

Can I show more than one validation error?

Yes. WS Form supports the display of one or more errors on the form, with each error stored in the field error action array.

Can validation messages appear before or after the form?

Yes. Messages can appear before or after the form, and message actions support additional options such as type, clear, scroll_top, scroll_top_offset, scroll_top_duration, form_hide, and duration.

How do I validate fields inside repeatable sections?

The field validation hook includes a section repeatable index parameter that represents the row index, starting with 1, when the field is inside a repeatable section.