var whitespace = " \t\n\r"; function isEmpty(s) { return ((s == null) || (s.length == 0)) } function isWhitespace (s) { var i; if (isEmpty(s)) return true; for (i = 0; i < s.length; i++) { var c = s.charAt(i); if (whitespace.indexOf(c) == -1) return false; } return true; } function warnInvalid (theField, s) { theField.focus() theField.select() alert(s) return false } function checkEmptyString (theField, s) { if (isWhitespace(theField.value)) return warnInvalid (theField, s); else return true; }