I copied this code, which successfully makes entering an email into my form mandatory, tweaked it slightly, hoping it would be enough to make adding a Contact Name mandatory, but it didn't work. What am I missing? You guidance will be appreciated. Thanks

[CODE]
<script type="text/javascript">
function checkcontact(){
var str=document.myform.contact_name.value;
var filter=/^([\w-]+(?:\.[\w-]+)*)((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
if(filter.test(str))
testresults=true;
else {
alert("Please input a valid contact name");
return false;
}
</script>
[CODE]