Got a question about validation in the frontend. Right now, I have a custom dashboard that I built that has validation working on it. no issues there.
My issue is that I need a way to switch tabs when the field in question doesn’t meet specifications. For example. Field A is under Tab B. I’m on Tab C currently. The validation kicks in on Tab A saying that it needs filled, but it’s not switching.
I know October does it in the backend, and I have some ways of doing it. I’d like some feedback on how to do it the “October” way with AJAX functions.
October CMS does it like this in the backend panel:
addEventListener('ajax:invalid-field', function(event) {
const { element, fieldName, errorMsg, isFirst } = event.detail;
if (!isFirst) {
return;
}
event.preventDefault();
// ... Find the tab from element and make it active ...
element.focus();
});
Not by default, the frontend is BYOT (bring your own tools/tech). However, you can implement this same code in the frontend. The only missing link is your tab implementation.