function checkForm()

{

   // the variables below are assigned to each

   // form input

   var name, message;



   with(window.document.formulario)

   {

      name    = name;

      comment = comment;

   }



   // if name is empty alert the visitor

   if(trim(name.value) == '')

   {

      alert('Please enter your name');

      name.focus();

      return false;

   }

 

   // alert the visitor if message is empty

   else if(trim(comment.value) == '')

   {

      alert('Please enter your message');

      comment.focus();

      return false;

   }

   else

   {

      // when all input are correct

      // return true so the form will submit

      return true;

   }

}



/*

Strip whitespace from the beginning and end of a string

*/

function trim(str)

{

   return str.replace(/^\s+|\s+$/g,'');

}



