Had a interesting requirement spec this week from a client that wanted to attach a status to the opportunity product entity. When it came to closing the quote, they wanted to only be able to do this if the opportunity product statuses were all closed (related to that opportunity)
Bit of playing around and searching led me to come up with this.
function canCloseOpp()
{
var canClose = false;
// validate if you can close the opp or not
return canClose;
}
var btnClose = document.getElementById('_MIcomplete');
if (btnClose)
{
btnClose.action = "if (canCloseOpp()) { complete(); } else { alert('Opportunity can not be closed whilst Opportunity Products are still in a open state'); }";
}