Restrict user to submit form (via onSubmit Client script)

61

onSubmit client script to prevent form submission

To prevent form submission using an onSubmit client script in ServiceNow, you can validate form fields and return false to stop the submission if certain conditions aren’t met. For example:

 

function onSubmit() {
    if (!g_form.getValue('required_field')) {
        g_form.addErrorMessage('This field is required.');
        return false;
    }
    return true;
}

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here