<html>
<head>
<script>
function notEmpty(elem, helperMsg){
if(elem.value.length == 0){
alert(helperMsg);
elem.focus();
return false; }
return true;}
</script>
</head>
<body>
<form>
Field #1: <input type="text" id="zone1" value="This field has text in it" /><br>
Field #2: <input type="text" id="zone2" value="" /><br><br>
<input type="button" onclick="notEmpty(document.getElementById('zone1'), 'sorry... empty field')" value="Check Field #1" /><br>
<input type="button" onclick="notEmpty(document.getElementById('zone2'), 'sorry... empty field')" value="Check Field #2" />
</form>
</body>