What is the way to write custom script on button?

I wan to run a custom script which should run on a button pressed
what should I do?

The fieldname of the button is the trigger.

frappe.ui.form.on("[DocType]", "[button_fieldname]", function(frm) { 
});
3 Likes

please give us full example
thank you