Make field mandatory using client script

divya123
Giga Contributor

how to make filed mandatory and read only using client script instead of using UI policies.

Regards

Divya

8 REPLIES 8

Harish KM
Kilo Patron
Kilo Patron

g_form.setMandatory('fieldname',true); // To make mandatory


g_form.setMandatoy('fieldname',false); //to make non-mandatory



g_form.setReadOnly('fieldname',true); // To make Readonly


g_form.setReadOnly('fieldname',false); //to make non-readonly


Regards
Harish

Thank you Harish for your response.


Np Divya. You can close the thread by marking appropriate answer..:)


Regards
Harish

Hello Harish,



I have a question. Suppose if I have more than 15 fields which should be visible and mandatory on Change of another field value, how can I make it mandatory? e.g., I have a select box field 'A' with choices 1-15. And I have around 15 other fields lets say (B-P), which should be visible and should be mandatory on change of field A's value. Also, as the choice increases the number of fields which should be visible also should increase. [e.g., If selected 1, then B field, if selected 2, then B, C fields, if selecetd 3,   then B,C,D fields should be visible.. and so on....


Writing a client script with setMandatory and setVisible for each field is too long. UI policy is also I guess is not feasible.



Is there any other way to achieve this?