это может быть то, что ты хочешь?
<form action="" name="someform">
<input type="text" name="inputname" />
<input type="submit" value="submit" />
</form>
<div id="warning"></div>
<script type="text/javascript">
function testForm ( e ) {
var inputname = this.inputname,
warning = false;
function isBlank ( elem ) {
return elem.value === "";
}
// tests elems, you may put it into a loop
if ( isBlank(inputname) ){
warning = "<span style=\"color:red;\">some warning</span>";
}
// output
if ( warning ){
e.preventDefault();
document.getElementById("warning").innerHTML=warning;
}
}
// bind
document.someform.onsubmit = testForm;
</script>