How to set field mandatory through client script?

aahitha2
Mega Expert

Hi,

I know that         g_form.setmandatory('fieldname'); //to set field mandatory in client script but i dont know how to create client script please can any one will help with screen short   that how can we use client script?

4 REPLIES 4

Shishir Srivast
Mega Sage

You can check all the information here: Client scripts


Nitin_NOW
Tera Guru

Are you trying to set the field mandatory onLoad() or onChange() ? Below are some useful links for your query.



Client side script for setting mandatory variables (g_form.setMandatory)


Variable set Mandatory!!


Make field mandatory using client script



Please hit correct based on impact of response.



Thanks


Mike Allen
Mega Sage

A) It would be g_form.setMandatory('fieldname', true);



B) It is easier to use UI Policies to govern this unless there is a specific use case, like changes from a state to another state



C) There are tons of examples in the OOB SN, like:



find_real_file.png



D) Please refer to the docs site for more info: GlideForm - Client


James Rostron1
Tera Expert

It's not stated in your original post what you would actually like to make mandatory.



As Mike Allen said it is best configuring UI Policies and setting conditions on which fields you wish to make mandatory. Much easier.