Código HTML:
<form name="tuform" method="post" onsubmit="return validar(this)">
<input type="text" value="" name="mytext">
</form>
Código HTML:
<script>
function validar(f) {
if (f.mytext.value == "") {
alert("debes colocar algo antes de grabar.")
f.mytext.focus();
return false
}
return true
}
</script>