This deletes all space characters from a form field's value and checks to see if the resulting string is empty. I think I got it's from the O'Reilly JS mega-ref. if ( myform.myfield.value.replace( /\s/g, '' ) == '' ) { ... return false; }