---
title: Custom validation
description: WP Data Access supports custom validation through JavaScript and database triggers. JavaScript validation 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…
url: "https://docs.legacy.wpdataaccess.com/docs/custom-validation/"
updated: "2025-11-26"
category: Legacy Tools / Forms / Advanced Features
---

# Custom validation

WP Data Access supports custom validation through JavaScript and database triggers. JavaScript validation 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.[/docs/query-builder/database-triggers/](/docs/query-builder/database-triggers/)

JavaScript 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 filter wpda_after_simple_form to add your validation function to a project used on the back-end. [Read more...](/docs/wpda_after_simple_form/)

Example

```
<?php
function my_validation_hook( $self ) {
    ?>
	<script>
	    function pre_submit_form() {
		    // Your validation code goes here...
			return true;
		} </script>
    <?php
}

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...](https://code-manager.com/blog/docs/index/server-code/back-end-code-php/)

## Add pre_submit_form() to front-end page[https://code-manager.com/blog/docs/index/shortcodes/javascript-shortcodes/](https://code-manager.com/blog/docs/index/shortcodes/javascript-shortcodes/)

  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...](https://code-manager.com/blog/docs/index/shortcodes/javascript-shortcodes/)

## Limitations

- JavaScript validation does not work with Data Forms.
