How to validate my button?

Hello,

How to put the validation on my custom button that it only appears when the record is submitted?

Thank You.

Check doc status

if(frm.doc.docstatus==1) {
	frm.add_custom_button(__("Test"), function() {
		
	});
}