Home › Forums › Gutenberg › Required fields in Gutenberg editor › Reply To: Required fields in Gutenberg editor
The solution I came up with as a fix was to use jquery to disable the publish / update button if the forms on the page don’t validate. It’s only briefly tested so I wouldn’t recommend on a production site without testing.
Make sure that this script is enqueued via file or is in <script> tags in the admin footer on the gutenberg edit page.
jQuery(document).ready(function($) {
$(window).bind("load", function () {
switch_publish_button_on_valid()
});
$("form :input").change(function() {
switch_publish_button_on_valid();
});
function switch_publish_button_on_valid(){
if($('form.metabox-location-normal')[0].checkValidity()){
$('button.is-primary').removeAttr('disabled');
} else {
$('button.is-primary').attr('disabled', 'disabled');
}
}
});
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.