The question in mandatory and chek

Hello guys,

What I need is that →
when the" web user" is checked , the “entry password” will change the status and become to Mandatory
but if the “web user” is not being check , the “entry password” will not change anything

and I wrote a Custom Script like

cur_frm.cscript.custom_before_insert= function(doc){
cur_frm.set_df_property("password", mandatory, doc.web_user=="1");

but it didn’t work , how can I do for it ?

BTW , the" web use" id is web_user
and the “entry password” id is password

The mandatory is set by reqd property …check it