DmitriSpartak, можно так:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<form action="/" method="POST">
<p><label>Ваше имя:<br/><input id="name2" name="name" type="text"/></label></p>
<p><label>Ваш телефон:<br/><input name="tel" id="tel2" type="text"/></label></p>
<p id="button_p">
<input name="button_f" value="ok" type="image" src="img/okbutton.png" alt="ОК">
</p>
</form>
<script>
var form = document.forms[0];
form.addEventListener('submit', function(e) {
var inpElems = form.querySelectorAll('input[type="text"]'),
result = true;
for(var i = 0; i < inpElems.length; i++) {
if( !inpElems[i].value.match(/^\S+/) ) {
result = false;
e.preventDefault();
}
}
if(!result) alert('Заполните все поля!');
});
</script>
</body>
</html>