1function isBlank(s) 2{ 3 if ( (s == null) || (s.length == 0) ) 4 return true; 5 6 for(var i = 0; i < s.length; i++) 7 { 8 var c = s.charAt(i); 9 if ((c != ' ') && (c != '\\n') && (c != '\\t')) 10 return false; 11 } 12 return true; 13} 14 15function validatecontact(frm) { 16 17 if (isBlank(frm.name.value)) { 18 alert ("Please enter a name"); 19 frm.name.focus(); 20 return false; 21 } 22 if (isBlank(frm.email.value) || frm.email.value.indexOf("@") == -1) { 23 alert ("Please enter your email address"); 24 frm.email.focus(); 25 return false; 26 } 27 28 if (isBlank(frm.content.value)) { 29 alert ("Please add a comment"); 30 frm.content.focus(); 31 return false; 32 } 33}