I use the MB jQuery validation for many fields in my frontend submission form. After the "Submit" button is clicked and fields have missing or invalid data, the page scrolls up to show where errors have occurred and highlights them - which is great.
This works fine on ALL fields except for the WYSIWYG custom field? When clicking "submit" and ONLY the WYSIWYG field is empty, NO scroll (to the error) action takes place. The "rwmb-error" class is shown below the field. This is problematic as I have a fairly lengthy form and the user has to scroll back up to locate the issue.
I am only using the
'required' => true, validation attribute on the WYSIWYG field. I see no errors in the browser console or in my error log file when this is triggered?
Is this a bug? I would very much like to solve this problem.
I look forward to your response?
Thanks in advance 🙂
Currently, Meta Box supports scrolling to the input field if the setting
true and the field is empty. For the WYSIWYG field, the input field
textarea will display if you switch to tab Text and you can see the browser scrolling to the field as well.
When you say....
For the WYSIWYG field, the input field textarea will display if you switch to tab Text and you can see the browser scrolling to the field as well.
Q) Are you suggesting I switch to using a 'textarea' or 'text' custom field type instead of the 'wysiwyg'? Because this allows for the scrolling to the field on error?
Although I appreciate switching field type will fix the scrolling issue you are effectively asking me to reduce the functionality I wish to provide to my users? I need the WYSIWYG to allow my users to format their posts?
Have I understood you correctly?
No, I don't suggest using the
text field. I mean the tab
Text of the WYSIWYG field, screenshot https://imgur.com/MS48uVF
It is the input field
textarea of the WYSIWYG field, the Visual tab hides the input field and the validation doesn't jump to the input field as you see.
thanks for clarifying. So I can see that when activating the text tab via the WYSIWYG options setting
'quicktags' => true that indeed the field is scrolled to when empty.
The problem is that I DO NOT want my users to use the "text" tab as arbitrary HTML can be added here?
A Hack (for anyone else using WYSIWYG Custom Field with NO TEXT TAB ONLY)
It is possible to trick scroll to validate field on the WYSIWYG.... it's a hack! But tested and works.
In your SAAS add the following:
// Set to your preferred height
display: block !important;
height: 0px !important;
What this does is force the <textarea> (the bit the validation needs to scroll up to) to be displayed but be visually hidden.
Thanks for sharing the workaround. I've escalated the issue to the development team to improve the scrollable feature for this field in future updates.
no probs... hacky... but works. Yeah, be nice to see this added as a feature to the validation methods.