Support

Account

Home Forums Front-end Issues Custom Validation Reply To: Custom Validation

  • Hi, Can you post an example of the full code. I’m really struggling..

    $field = jQuery( 
    What should I write here - Field type, name, id ? with quotes or without ? 
    );

    And should I change the field here or location of acf/validate_field:
    jQuery(document).on('acf/validate_field', function( e, field ){

    I want to get a simple dummy false validation to check if it is working:

    jQuery(document).on('acf/validate_field', function( e, field ){
    	$field = jQuery(field);
    	$field.data('validation', false);
    });

    Notes:
    I have hooked the .js file like this:

    add_action( 'wp_enqueue_scripts', 'my_enqueue_styles_scripts' );
    function my_enqueue_styles_scripts() {
    	wp_enqueue_script( 'acf-custom-validation', get_template_directory_uri() .'/js/acf-validation.js', array( 'acf-input' ) );
    }