Custom javascript

Hello,
Can anyone suggest if we write JSON with two textfield and one button then how to write custom javascript on these three

for example :- Can we write onchange or onfocus event on both textfield then what ID or class i can use

please write an example for this

In the form’s JS script this will give you the input object.

frappe.ui.form.on("My Doctype", "setup", function(frm) {
  cur_frm.get_field("fieldname").$input
}

Will be better if you can explain the use case.

hello sir, I have been change a field on another field focus so above you tell the way of custom javascript this is not work on other javascript handler like (onmousehover,onfocus,onclick etc)

can u please suggest how to write this.

Can you share your use case? How do you want to use it?