Font Size:
Ask Joget AI

Temporarily Disable Form Validation on Button Click

Introduction

Sometimes, you may need to bypass form validation, such as when rejecting a request. This can be achieved by using a Bean Shell Load Data Store. Adding a dummy section to your form and when a specific button is clicked or a specific field value is selected.

There are two methods available to implement this functionality. Below, we will explore each method, providing step-by-step guidance to help you effectively integrate them into your Joget forms.

Method 1: bypass validation by clicking on the reject button 

This method relies on the Reject button generated by the Process Enhancement Plugin (button ID process_reject) which is on default for Joget DX 9.1. If you are using the plugin, you can enable Skip Validation? (Reject) under Map Activities to Forms - More Settings instead, without using the script below.

To bypass validation by clicking on the reject button, follow these steps:

  1. Add an empty or dummy section to your form. 
  2. Change the section's load Data Store to a Bean Shell Load Data Store and insert the following script.
    import org.joget.apps.app.service.AppUtil;
    import org.joget.apps.form.service.FormUtil;
    import org.joget.apps.form.model.Element;
    import org.joget.apps.form.model.Form;
    import org.joget.apps.form.model.FormData;
    import org.joget.apps.form.model.FormRowSet;
    
    public FormRowSet load(Element element, String primaryKey, FormData formData) {
        // Change this condition to suit your needs
        if (formData.getRequestParameter("process_reject") != null) {
            Form form = FormUtil.findRootForm(element);
            removeValidator(form, formData);
        }
        return null;
    }
    
    public void removeValidator(Element e, FormData formData) {
        e.setValidator(null);
    
        Collection children = e.getChildren(formData);
        if (children != null) {
            for (Element child : children) {
                removeValidator(child, formData);
            }
        }
    }
    
    // Call load method with injected variable
    return load(element, primaryKey, formData);

Method 2: bypass validation using a select box

To bypass validation using a button inside the form, follow these steps:

  1. Add an empty or dummy section to your form. 
  2. Change the section's load Data Store to a Bean Shell Load Data Store and insert the following script, replacing "disable_validation" with the ID of the select box form element and "Disable" with the option value that will disable validation.

    import org.joget.apps.app.service.AppUtil;
    import org.joget.apps.form.service.FormUtil;
    import org.joget.apps.form.model.Element;
    import org.joget.apps.form.model.Form;
    import org.joget.apps.form.model.FormData;
    import org.joget.apps.form.model.FormRowSet;
    
    public FormRowSet load(Element element, String primaryKey, FormData formData) {
        // Get disable_validation value from form data object
        String disableValidatorID = "disable_validation";
        Form form = FormUtil.findRootForm(element);
        Element disableValidatorElement = FormUtil.findElement(disableValidatorID, form, formData);
        
        if (disableValidatorElement != null) {
            // Get value of disable validator
            String[] disableValidatorValues = FormUtil.getElementPropertyValues(disableValidatorElement, formData);
            for (int i = 0; i < disableValidatorValues.length; i++) {
                System.out.println("Toggle Button Value " + i + ": " + disableValidatorValues[i]);
                // Remove validator if checkbox value = Disable
                if (disableValidatorValues[i].equalsIgnoreCase("Disable")) {
                    removeValidator(form, formData);
                    break;
                }
            }
        }
        return null;
    }
    
    public void removeValidator(Element e, FormData formData) {
        e.setValidator(null);
        
        Collection children = e.getChildren(formData);
        if (children != null) {
            for (Element child : children) {
                removeValidator(child, formData);
            }
        }
    }
    
    // Call load method with injected variable
    return load(element, primaryKey, formData);

Related documentation

Download sample app

Download the demo app for Temporarily Disable Form Validation on Button Click:
Created by Aadrian Last modified by Nur Baizura Badrul Sham on Nov 13, 2026