// JavaScript Document

function checkForm(contactform) {       

   var why = '';         



    why += checkname(contactform.name.value);

    why += checkcountry(contactform.country.value);

    why += checkemail(contactform.email.value);

    why += checkcomment(contactform.comment.value);      

    if (why != '') {

       alert(why);

       return false;

    }

return true;



}



 



 



// username - 4-10 chars, uc, lc, and underscore only.



 



function checkname(strng) {



var error = "";



if (strng == "") {



   error = "Please enter your name.\n";



}



 



 



     var illegalChars = /\W/; // allow letters, numbers, and underscores



     if (illegalChars.test(strng)) {



    error = "The name contains illegal characters.\n";



    } 





return error;



} 











 



 



function checkcountry(strng) {



var error = "";



if (strng == "") {



   error = "Please enter country.\n";



}



 



 



     var illegalChars = /\W/; // allow letters, numbers, and underscores



     if (illegalChars.test(strng)) {



    error = "The country contains illegal characters.\n";



    } 


      







    



return error;



}



function checkemail (strng) {



var error="";



if (strng == "") {



   error = "Please enter an email address.\n";



}



 



    var emailFilter=/^.+@.+\..{2,3}$/;



    if (!(emailFilter.test(strng))) { 



       error = "Please enter a valid email address.\n";



    }



    else {



//test email for illegal characters



       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/



         if (strng.match(illegalChars)) {



          error = "Invalid email address.\n";



       }



    }



return error;    



}



function checkcomment(strng) {



var error = "";



  if (strng.length == 0) {



     error = "Please enter your comment.\n"



  }



return error;         



}



 

