Prevent submit/UI action

MarkNow
Giga Contributor

Hi everyone, I'm trying to prevent incident submissions with short descriptions (less than 10 characters) using a UI Action script . I've created the script to show an error message and prevent submission, but it's not working as intended. When I click Submit, the incident still opens even if the description is too short.

I've tried using a Client Script, and that works correctly. Is there a way to achieve this using a UI Action?

Additionally, I'd like to add two empty lines after the error message within the same frame. Is this possible?

Any help would be greatly appreciated!

 

Please find the the client script that I have used, but I would like to obtain the same result via UI action

function onSubmit() {
   var shortDescription = g_form.getValue('short_description');
    if (shortDescription.length < 10) {
        g_form.showFieldMsg('short_description', 'The title is too short (less than 10 characters).' , 'error');
        g_form.showFieldMsg('short_description', '*Please check' , 'error');
    }
    return false; // Prevent submission
   
}
0 REPLIES 0