Title: No validation message returned
Last modified: August 21, 2016

---

# No validation message returned

 *  Resolved [aboother](https://wordpress.org/support/users/aboother/)
 * (@aboother)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/no-validation-message-returned/)
 * Hi,
 * I added a validated text field to my custom field group, with basic PHP validation
   as below:
 *     ```
       <?php
       if(strlen($value) < 10) {
           $message = "Test alert";
           return false;
       } else {
           return true;
       }
       ```
   
 * I then entered less than ten characters in the field on the post page and clicked‘
   publish’ to test this, expecting my error message to pop up, but it did not do
   so. In fact WordPress would not even save my changes, it just hangs and doesn’t
   actually reload the page.
 * Please can anyone shed some light as to what the issue may be?
 * Cheers.
 * [https://wordpress.org/plugins/validated-field-for-acf/](https://wordpress.org/plugins/validated-field-for-acf/)

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Author [doublesharp](https://wordpress.org/support/users/doublesharp/)
 * (@doublesharp)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/no-validation-message-returned/#post-4870827)
 * [@aboother](https://wordpress.org/support/users/aboother/) – It sounds like you
   are running into a JavaScript error. Can you let me know what OS/browser you 
   are using, and also check to see if there is anything in the JavaScript console
   that may be relevant?
 *  Thread Starter [aboother](https://wordpress.org/support/users/aboother/)
 * (@aboother)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/no-validation-message-returned/#post-4871007)
 * [@doublesharp](https://wordpress.org/support/users/doublesharp/) – I’m running
   the latest version of Chrome, I’m getting no JS errors in the console I’m afraid.
   I’m using the latest versions of both the ACF plugin and the ACF validation plugin
   and am running WordPress 3.9 too.
 * It seems like the validation partly works as the page doesn’t submit, but I just
   don’t get any validation messages pop-up and can’t submit the page thereafter
   no matter how many characters I enter into the field.
 * Any ideas would be appreciated.
 *  Plugin Author [doublesharp](https://wordpress.org/support/users/doublesharp/)
 * (@doublesharp)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/no-validation-message-returned/#post-4871089)
 * Are you creating a Post, Custom Post, or Page? Your sample code works fine for
   me using a CPT with a text field.
 * If you have the developer tools open in Chrome on the Network tab when you click
   the Publish/Update button you should see a request to `/admin-ajax.php` – can
   you copy the “Form Data” section as well as the JSON Response?
 *  Thread Starter [aboother](https://wordpress.org/support/users/aboother/)
 * (@aboother)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/no-validation-message-returned/#post-4871122)
 * Hi,
 * I’m using a custom post. The form data returns:
 * _[ Moderator note: Code fixed, please wrap code in [backticks or use the code button](http://codex.wordpress.org/Forum_Welcome#Posting_Code).]_
 *     ```
       action=validate_fields&post_id=494&fields%5B0%5D%5Bid%5D=fields%5Bfield_536226330aa1f%5D&fields%5B0%5D%5Bvalue%5D=test&fields%5B0%5D%5Bvalid%5D=false
       ```
   
 * Under the ‘preview’ tab when I’ve clicked on ‘admin-ajax.php’, the following 
   is returned:
 *     ```
       <b>Notice</b>: Undefined variable: php in <b>/website/theme/wp-content/plugins/validated-field-for-acf/validated_field_v4.php</b> on line <b>135</b> [{id:fields[field_536226330aa1f], message:Test Alert, valid:false}]
       0: {id:fields[field_536226330aa1f], message:Test alert, valid:false}
       id: "fields[field_536226330aa1f]"
       message: "Test alert"
       valid: false
       ```
   
 * This looks like it may be causing an issue?
 *  Plugin Author [doublesharp](https://wordpress.org/support/users/doublesharp/)
 * (@doublesharp)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/no-validation-message-returned/#post-4871135)
 * It is indeed the issue – I don’t have `E_STRICT` enabled on my laptop so I wasn’t
   getting that notice. Everything is evaluating correctly (which is why the proper
   message is present) but I am appending to a variable called `$php` before creating
   it which is breaking the JavaScript since it’s not valid JSON.
 * I’ll push out an update with this fixed this afternoon, thanks!
 *  Plugin Author [doublesharp](https://wordpress.org/support/users/doublesharp/)
 * (@doublesharp)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/no-validation-message-returned/#post-4871136)
 * [@aboother](https://wordpress.org/support/users/aboother/) Version 1.1.1.1 should
   fix this issue for you, thanks!
 *  Thread Starter [aboother](https://wordpress.org/support/users/aboother/)
 * (@aboother)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/no-validation-message-returned/#post-4871138)
 * Excellent, thanks [@doublesharp](https://wordpress.org/support/users/doublesharp/)
   that’s fixed the issue.
 * Just a small thing to note. I have made the field a ‘required field’. If I go
   to submit the post without any characters in the field, it flags up that the 
   field is required which is right. I then enter just one character, and although
   my PHP validation should show a message if the value is less than 10 character(
   as per my first post), no message shows and I can save the post changes. Therefore
   I can save the post with less than 10 characters in this validated field.
    If
   I then go to save the post again without making any changes, the validation works
   and the message appears to say the validated field has less than 10 characters.
   So basically this validated message doesn’t work the first time round but does
   there after.
 * If you can think of any reasons for this that would be great.
 * Cheers.
 *  Plugin Author [doublesharp](https://wordpress.org/support/users/doublesharp/)
 * (@doublesharp)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/no-validation-message-returned/#post-4871149)
 * [@aboother](https://wordpress.org/support/users/aboother/) Can you please upgrade
   to version 1.2 and give it another try? If you are still having issues please
   open a new ticket. Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘No validation message returned’ is closed to new replies.

 * ![](https://ps.w.org/validated-field-for-acf/assets/icon-256x256.png?rev=1116693)
 * [Advanced Custom Fields: Validated Field](https://wordpress.org/plugins/validated-field-for-acf/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/validated-field-for-acf/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/validated-field-for-acf/)
 * [Active Topics](https://wordpress.org/support/plugin/validated-field-for-acf/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/validated-field-for-acf/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/validated-field-for-acf/reviews/)

## Tags

 * [validation](https://wordpress.org/support/topic-tag/validation/)

 * 8 replies
 * 2 participants
 * Last reply from: [doublesharp](https://wordpress.org/support/users/doublesharp/)
 * Last activity: [12 years, 1 month ago](https://wordpress.org/support/topic/no-validation-message-returned/#post-4871149)
 * Status: resolved