1. Home
  2. Docs
  3. Data Projects
  4. Custom validation

Custom validation

WP Data Access supports custom validation through JavaScript. Usage is very simple, just add a JavaScript function named pre_submit_form() to your page which handles the validation. The plugin will automatically execute your pre_submit_form() function before data is submitted to the server.

Validation example

function pre_submit_form() {
	if ( jQuery("#check_code").length < 6 ) {
		alert("ERROR Check code must be at least 6 characters");
		return false; // this tells WP Data Access your validation failed
	// Add more validations here...

	return true; // this tells WP Data Access your validation succeeded

Add pre_submit_form() to back-end page

Use action hook wpda_after_simple_form to add your validation function. Read more…


function my_validation_hook( $self ) {
		function pre_submit_form() {
			// Your validation code goes here...
			return true;

if ( isset( $_REQUEST['page'] ) && 'wpda_wpdp_21_24' === $_REQUEST['page'] ) {
	// Validation is added to project id 21 page 24 only
	add_action( 'wpda_after_simple_form', 'my_validation_hook', 10, 1 );

The premium version of the Code Manager supports back-end coding. Read more…

Add pre_submit_form() to front-end page

Use the Code Manager (free version) for projects executed on the front-end with shortcode wpdadiehard. Just add your validation function to the page running the wpdadiehard shortcode. That’s all! Read more…


Custom validation does not work with Data Forms.

Was this article helpful to you? Yes No

Leave a Reply

Your email address will not be published.