This may not use C# but it looks more like the validation done on the MOSS forms because it uses a new span above the text box instead of an alert pop-up:
<script type="text/javascript">
function PreSaveAction()
{
var findDate = getTagFromIdentifierAndTitle("input","DateTimeFieldDate","Due Date");
var findText = getTagFromIdentifierAndTitle("textarea","","Test");
var txt = document.createElement("span");
txt.className = "ms-formvalidation";
if(findDate.value != "" && findText.value == "")
{
txt.appendChild(document.createTextNode("You must provide a Justification for the Due Date"));
txt.id = "val1";
if (document.getElementById("val1")){
}else{
findText.parentNode.insertBefore(txt, findText);
}
return false; // Cancel the item save process
}
return true; // OK to proceed with the save item
}
function getTagFromIdentifierAndTitle(tagName, identifier, title) {
var len = identifier.length;
var tags = document.getElementsByTagName(tagName);
for (var i=0; i < tags.length; i++) {
var tempString = tags[i].id;
if (tags[i].title == title && (identifier == "" || tempString.indexOf(identifier) == tempString.length - len)) {
return tags[i];
}
}
return null;
}
//-->
</script>