Don't validate black values, simply filter them out, so the user cannot enter them.
For example:
<html>
<head>
<script type="text/javascript"><!--
function filterBlank(eventInstance) {
eventInstance = eventInstance || window.event;
key = eventInstance.keyCode || eventInstance.which;
if (key != 32) {
return true;
} else {
if (eventInstance.preventDefault)
eventInstance.preventDefault();
eventInstance.returnValue = false;
return false;
}
}
--></script>
</head>
<body>
<input type="text" onkeypress="filterBlank(event)"/>
</body>
</html>
—SA