I did it recently with jQuery, http://endusersharepoint.com/STP/viewtopic.php?f=13&t=2916&start=10
This is what the code looks like in my scenario, something could be adapted for your use.
<script src="../../Resources/jquery.js" type="text/javascript"></script>
<script src="../../Resources/SPServices.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
var text = $("input[title$='VenLookup']").val();
var text2 = $("select[title$='VenLookup'] :selected").text();
if(text != "Other - Not Listed" || text2 != "Other - Not Listed")
{
$(".VendorDetails").hide();
}
//For IE
$("input[title$='VenLookup']").change(function() {
var inputTextVal = $("input[title$='VenLookup']").val();
if(inputTextVal == "Other - Not Listed")
{
alert('Please fill out all the vendor fields that will appear on the form');
$(".VendorDetails").show();
$(".VendorLabel").append("<span class='ms-formvalidation'> *</span>");
}
else {}
});
// For Firefox
$("select[title$='VenLookup']").change(function() {
var selectTextVal = $("select[title$='VenLookup'] :selected").text();
if(selectTextVal == "Other - Not Listed")
{
alert('Please fill out all the vendor fields that will appear on the form');
$(".VendorDetails").show();
$(".VendorLabel").append("<span class='ms-formvalidation'> *</span>");
}
else {}
});
function PreSaveAction() {
$().SPServices({
operation: "GetListItems",
async: false,
listName: "Labs",
CAMLQuery: "<Query><Where><Eq><FieldRef Name='Lab_x0020_Location'/><Value Type='Text'>" + $("input[title$='Lab']").val() + "</Value></Eq></Where></Query>",
completefunc: function (xData, Status) {
$(xData.responseXML).find("[nodeName='z:row']").each(function() {
$("input[title='Lab ID']").val($(this).attr("ows_LabID"));
}); //close each
} //close complete
}); //close SPServices
var Intext = $("input[title$='VenLookup']").val();
var Seltext = $("select[title$='VenLookup'] :selected").text();
if(Intext != "Other - Not Listed" || Seltext != "Other - Not Listed")
{
$("tr.VendorDetails input").each(function() {
error = false;
if ($(this).val().length <= 0) {
error = true;
}
});
if (error)
{
alert("Please fill out all required fields");
return false;
}
else
{
return true;
}
}
} // close presave
}); //end doc ready
</script>