Issues in making custom script

I have added custom field ‘validity acc to today’ as read only in ‘bank guarantee’ doctype.
I wrote the following custom script in

but when I open new bank guarantee I am getting this error:

SyntaxError: missing ) after argument list

You’re missing a semi-colon in your line var i = b-d.

thank you … I added semicolon. but still getting the same error.
How to fix this?

You’re also missing quotes - 'Bank Guarantee'

I am getting error :
Uncaught (in promise) ReferenceError: cdt is not defined

Because it is not defined. refresh: function(frm, cdt, cdn) {
Please consider going through already created similar scripts or documentations and then try instead of expecting to get results like this.

why did you write this custom script ???