Try ERPNext Buy Support Partners Foundation

Custom Script to update date

I have written following custom script to update reference_date(chq date) based on posting_date(entry date) in “Payment Entry” doc type.
Now I want to put condition that reference_date should be updated only when it is empty. Please suggest how to put that condition.

cur_frm.cscript.posting_date = function(doc){
cur_frm.set_value(“reference_date”, doc.posting_date);
};