New Validation System

Please Note

This document is only relevant for WC Vendors Pro 1.5.0 and above

In Version 1.5.0 of WC Vendors Pro the Validation system has been completely replaced with a new system. The new system provides a much cleaner validation system for you to use. There is a built in translator for any custom form code you may have in your theme to help with the transition. This means all your existing custom form validation rules will continue to work. You will however get an error log notice informing you to update, to the new system.

All validation rules and messages are handled via the form fields ‘custom_attributes’. To override or add validation rules you will need to find the fields filter name, located in the source code and then add the values you require.

Validation is run on every field before the form is submitted so your users will know instantly if they have entered an incorrect value.

Required Field

To make a field required all you have to do is set the HTML 5 required attribute on the field and it will become required. The following example shows how to make the SKU field required.

// Add this to your themes functions.php 
add_filter( 'wcv_product_sku', 'wcv_product_sku' );
function wcv_product_sku( $field ){
	$field[ 'custom_attributes' ] = array( 'required' => "", 'data-parsley-error-message' => 'SKU is required' );
	return $field;

Custom Error message

To add a custom error message you can use the new data value ‘data-parsley-error-message’. As you can see in the SKU example above this will output a new error message. By default you will get a generic error message. This is only required if you would like to give your users more context for the error.


There are many different validation rules available with Parsley and you can find them in the parsley documentation below.

Read the full Parsley JS documentation here. 


Updated on February 26, 2018

Was this article helpful?