1function isBlank(s){ 2 if ((s === null) || (s.length === 0)){ 3 return true; 4 } 5 6 for (var i = 0; i < s.length; i++){ 7 var c = s.charAt(i); 8 if ((c != ' ') && (c != '\n') && (c != '\t')){ 9 return false; 10 } 11 } 12 return true; 13} 14 15function validate(frm){ 16 if (isBlank(frm.mail.value) || frm.mail.value.indexOf("@") == -1){ 17 frm.mail.focus(); 18 return false; 19 } 20 if (isBlank(frm.name.value)){ 21 frm.name.focus(); 22 return false; 23 } 24 25 if (isBlank(frm.text.value)){ 26 frm.text.focus(); 27 return false; 28 } 29}