How to hide mandatory fields through client script?

ram2497
Tera Contributor

How to  hide mandatory fields through client script?

5 REPLIES 5

Chandra Prakash
Tera Expert

Hi Ram,

If there is a mandatory field you cant make it read only or hide it, so before you have to hide you make the field non mandatory.

Similarly, if a field is read only you cant make it mandatory, you first need to make it editable n then make it mandatory.

 

Regards,
Chandra Prakash

Chandra Prakash
Tera Expert

Hi Ram,

Try with g_form.checkMandatory = false; to ignore all mandatory fields on the form.

Mark correct if it helps.

Regards,

Chandra Prakash

its not working

Priyanka136
Mega Guru

Hi Ram,

You have to write OnChange Client Script. Try with this Simple sample script below. You have to change the (field_name) accordingly.

function onChange(control, oldValue, newValue, isLoading, isTemplate)
{
   if (isLoading || newValue === '')
   {
      return;
   }

	if(newValue == 'PUT THE FIELD VALUE HERE')
	{
		
		g_form.setMandatory('field_name', false);

		g_form.setDisplay('field_name', false);
	}

	else
	{

		g_form.setMandatory('field_name', true);

		g_form.setDisplay('field_name', true);

	}
	
}

Let me know if you have any questions.

Please mark it Correct or Helpful, if it works based on impact....!!!!

Warm Regards,

Priyanka

find_real_file.png

www.dxsherpa.com