We’ve implemented custom JavaScript validation for our incident forms in Qualio 2022.2 to enforce specific compliance requirements. The script should validate severity levels against incident types before allowing save operations.
The validation logic works perfectly when triggered manually via browser console, but it’s not firing automatically when users click the Save button. I’ve bound the validation to the form’s save event using Qualio’s custom form hooks, and there are no console errors appearing. I’ve tested across Chrome, Firefox, and Edge with identical results.
Here’s the event binding approach:
Qualio.forms.onBeforeSave('incident', function(formData) {
return validateSeverityMatch(formData.severity, formData.type);
});
The validateSeverityMatch function executes correctly when called directly, so the issue seems to be with the event hook registration itself. Has anyone encountered similar behavior with custom form validation scripts in Qualio?
I’ve worked extensively with Qualio’s form customization framework. Another common issue is the event propagation being stopped by Qualio’s internal validation before your custom hook executes. Check if Qualio’s built-in required field validation might be failing first, preventing your custom validation from ever being reached. You can verify this by temporarily removing all required field markers from your incident form and testing again.
I ran into something similar last month. Check if your script is loading before Qualio’s form framework initializes. The timing matters significantly with client-side customizations. Try wrapping your event binding in a document ready handler or Qualio’s initialization callback if available. Also verify that the form ID you’re targeting matches exactly - ‘incident’ vs ‘incident-form’ can make a difference depending on your Qualio version.
The onBeforeSave hook you’re using might not be the correct API method for 2022.2. Qualio’s client-side API evolved between versions. In 2022.2, you might need to use the addEventListener pattern instead. Also, check your browser’s Network tab to confirm the custom JS file is actually loading on the incident form page. Sometimes path issues prevent the script from loading entirely, which would explain why manual execution works but automatic triggering doesn’t.
Also worth checking: does your form have any conditional fields that might affect the save event chain? In some Qualio versions, conditional logic can interfere with custom event handlers if the conditions aren’t properly resolved before save. Try testing on a simplified incident form with minimal fields first.
Good point about the loading order. I’ve confirmed the script loads successfully - I can see it in the Sources tab and the validateSeverityMatch function is accessible globally. The file loads via a custom extension we configured in Qualio’s admin panel under Client Extensions. I haven’t tried wrapping it in a ready handler though. Would that be Qualio.ready() or standard jQuery $(document).ready()?
After reviewing your code snippet and considering the symptoms, I’ve identified the root cause. The issue stems from how Qualio 2022.2 handles custom JavaScript event binding combined with browser compatibility considerations.
Custom JavaScript Event Binding: The onBeforeSave method you’re using exists in the API, but it requires proper initialization context. Wrap your entire binding in Qualio.ready() to ensure the form hooks are fully registered:
Qualio.ready(function() {
Qualio.forms.onBeforeSave('incident', function(formData) {
return validateSeverityMatch(formData.severity, formData.type);
});
});
Qualio Form Hooks: The form ID must match exactly as defined in Qualio’s form registry. Use the browser console to verify: Qualio.forms.getRegisteredForms() will list all available form IDs. You might need ‘incident-create’ or ‘incident-edit’ instead of just ‘incident’.
Browser Compatibility: Ensure your validateSeverityMatch function returns a boolean explicitly. Some browsers handle implicit returns differently in event callbacks. Also, if validation fails, return false AND call event.preventDefault() if the event object is passed to your callback.
No Console Errors: The absence of errors suggests your code is syntactically correct but not executing in the right lifecycle phase. This confirms it’s a timing/initialization issue rather than a code error.
Manual Trigger Works: This proves your validation logic is sound. The problem is purely with automatic event attachment.
Additional debugging step: Add console.log statements inside both Qualio.ready() and your validation callback to confirm execution timing. If you see the ready log but not the validation log on save, the form ID is incorrect. If you see neither, there’s a script loading issue despite what the Sources tab shows.
For 2022.2 specifically, also verify that your Client Extensions configuration has the script set to load on ‘Form Pages’ scope, not just ‘All Pages’. The scope setting affects when and how the script initializes within Qualio’s framework.
For Qualio 2022.2, use Qualio.ready() specifically. The framework has its own initialization sequence that’s separate from standard DOM ready events. jQuery might fire before Qualio’s form hooks are fully registered, causing your binding to attach to nothing. Also double-check that you’re not accidentally overwriting the hook elsewhere in your codebase. Multiple scripts trying to bind to the same form event can cause conflicts where only the last one registers properly.