function validate(f) { if((f.name.value == null) || (f.name.value == "") || isblank(f.name.value)){ alert("You must give a name"); f.name.focus(); return false; }; // check to see if the email's valid if (!validEmail(f.email.value)) { alert("Invalid email address"); f.email.focus(); f.email.select(); return false; }; // make sure user choose a rate rateOption = -1; for (i=0; i -1) { return false; }; }; atPos = email.indexOf("@",1); // there must be one "@" symbol if (atPos == -1) { return false; }; if (email.indexOf("@",atPos+1) != -1) { // and only one "@" symbol return false; }; periodPos = email.indexOf(".",atPos); if (periodPos == -1) { // and at least one "." after the "@" return false; }; if (periodPos+3 > email.length) { // must be at least 2 characters after the "." return false; }; return true; } // utility function that returns true if a string contains only // whitespace chars function isblank(s){ for(var i = 0; i < s.length; i++){ var c = s.charAt(i); if((c != ' ') && (c != '\n') && (c != '\t')) return false; }; return true; }