Custom Script Onchange event

Hi ,
I have to write a custom script for material request item to compare two fields X and Y .and if X=Y then change field Z to read only .
How to write custom script for onchange event of a textbox Y.
Please Help .

@Shashank_Mishra take a look in to this! Not Found