How to check if a field on the form is visible in Client Script?

Ashish70
Giga Contributor

I have a field on a form which I want to verify as being hidden/ empty. The field would be hidden if it is empty as that part is already built in. I want to find out if the field is visible or if the field is empty on the form in a client script. Please help. Thanks.

1 ACCEPTED SOLUTION

JayGervais
Kilo Sage

You could do a check like this.

if (g_form.isVisible('field') || g_form.getValue('field') != '') {

  // check if the field is visible or has a value

}

View solution in original post

7 REPLIES 7

BryanS413339635
Tera Guru

This community post may help: check visibility of variable

Willem
Giga Sage
Giga Sage

On a form in the back-end you can use

g_form.isVisible("fieldName");

It will return true if the field is visible.

JayGervais
Kilo Sage

You could do a check like this.

if (g_form.isVisible('field') || g_form.getValue('field') != '') {

  // check if the field is visible or has a value

}

pawel_staszewsk
Giga Guru

I am not sure why, but for me it works only when I do:

var priElement = g_form.getGlideUIElement('priority');
var priControl = g_form.getControl('priority');
if (g_form.isVisible(priElement, priControl)) 
   g_form.setMandatory('priority', true);