Home › Forums › Front-end Issues › Required fields validation
Hi,
I have a form with required fields. When I submit it with my required fields empty, it still creates a new post without any error.
I was wondering if ACF is supposed to automaticaly do a validation and show an error message if the required fields are empty or if I need to do it manually adding some code somewhere. If so, how should I do it ? I didn’t find anything about it.
I’m using the free version of ACF.
Thanks for your help.
ACF should be checking these, usually. Make sure that you have placed acf_form_head()
before get_header()
and that your theme includes both wp_head()
and wp_footer()
calls.
Thank you for your answer. I already placed acf_form_head() before get_header() and wp_head() and wp_footer() are called in my theme. Is there anything else which could cause this issue ?
Very good question. I just did a quick test and it seems to be working as expected. Other things that can cause this include incompatibility with other plugins and/or something in the theme.
Most probably it has something to do with a JavaScript error or a PHP error during the AJAX request that does the validation. First thing to do is look in console and see if any JS errors are reported on the page. Next thing is to enable debugging and error logging and look in your error log to see if there are any PHP errors that could be causing the AJAX request to fail. https://codex.wordpress.org/WP_DEBUG
Ok thanks,
I checked and there is no javascript error. There were some PHP errors that I fixed but the issue remains. There’s still no validation going on. I really don’t understand why it’s not working if there’s no errors…
I did a test and the only way I could get ACF4 to not validate fields set as required was to turn off JavaScript on the test site. This means that for some reason the JS is not running, or maybe not even being loaded, or that there is a JS error stopping it from working.
Have you tried deactivating your other plugins or switching themes to see if anything might be interfering with ACF?
The topic ‘Required fields validation’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.