Change filed mandatory property based on other filed selection

i use the custom script
cur_frm.cscript.custom_mandatory_filed = function(doc){
cur_frm.set_df_property(“margin”, “reqd”, doc.type==“LG Final”);}

to set filed margin mandatory when select type is LG Final but it’s not working Any help

which trigger is this?

if you have a type named field, you can make the trigger on that,

type: function(frm) {
		cur_frm.set_df_property("margin", "reqd",doc.type=="LG Final");

Dear Sangram

i edit script as you post
type: function(frm) {
cur_frm.set_df_property(“margin”,“reqd”,doc.type==“LG Final”);

I got this error
SyntaxError: Unexpected token (
at Class.setup (http:///assets/js/form.min.js:2578:17)
at _f.Frm.setup (http:///assets/js/form.min.js:172:22)
at _f.Frm.refresh (http:///assets/js/form.min.js:439:9)
at Class.load (http:///assets/js/form.min.js:87:33)
at http:///assets/js/form.min.js:82:7
at Object.callback (http:///assets/js/desk.min.js:6556:6)
at Object.callback [as success_callback] (http:///assets/js/desk.min.js:1201:16)
at _ (http:///assets/js/desk.min.js:1225:34)
at Object. (http:///assets/js/desk.min.js:1321:4)
at i (http:///assets/frappe/js/lib/jquery/jquery.min.js:2:27151)