The following example shows the onClick event handler for a Cancel button. It checks if any changes have been made to the current record. If there has, it asks for confirmation before abandoning the changes.

function cancelButton_onClick( )

if form.isRecordChanged( ) 

if msgbox( "Are you sure you want to lose these changes?", "Cancel", 4+32 ) # 6 

return // Did not choose Yes, don't cancel (or anything else) 

endif 

else 

  form.abandonRecord( )

 endif