How to hide mandatory fields through client script?

ram2497
Tera Contributor

How to  hide mandatory fields through client script?

5 REPLIES 5

Rahul Kumar17
Tera Guru

Hi Ram,

Here's an example of how you can use client-side scripting to hide mandatory fields:

 

function onLoad() {
    var mandatoryField = g_form.getControl('mandatory_field');
    if(mandatoryField) {
        mandatoryField.setAttribute('style', 'display:none');
        g_form.setMandatory('mandatory_field', false);
    }
}

 

In this example, the onLoad() function is called when the form is loaded. The g_form.getControl('mandatory_field') function is used to get a reference to the mandatory field control, and the setAttribute() function is used to set the display style to none to hide the field from the UI. Additionally, the g_form.setMandatory('mandatory_field', false) function is used to remove the mandatory requirement from the field.

Please note that this is just an example and the implementation may vary based on your specific requirements.

 

Thanks,

Rahul Kumar

If my response helped please mark it correct and close the thread.

Thanks,
Rahul Kumar