as an evil one-liner:
<input onBlur="alert(this.value.match(/[\w\d]/)!=null?'OK':'NOT OK');">
or more useably:
function check_field(ident){
var target = document.getElementById(ident);
return target.value.match(/[\w\d]/) != null;
}
function check_form(){
if(check_field('the_one_that_can't_be_spaces')){
//Everything's fine!
}else{
//Something's missing o_O
}
}
if the String.match(/regex/) function returns a valid match for \w (any alphabetic character) or \d (any number) (notation [\w\d]) then theres nothing valid in the field.. change the regex to change the matching cases.
Some reading may be helpful: http://www.webreference.com/js/column5/
(^ this ones a bit lame to be honest, check out the PERL regex tutorials, the syntax once your in an expression is identical: http://www.perl.com/pub/a/2000/11/begperl3.html )
if you want to trim the string... you can do a String.split(/[ ]{1,}/) (returns a String array); but if you don't know what's been entered you may need alot of logic to work out where your (valid) values are... if you split by an indefinate number of spaces ([ ]{1,}) then if the string is all spaces; the length of the resulting array (should) be 0...