function checkEmail(txt){ var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/ return b.test(txt) } function checkContactForm(){ if('' == document.getElementById('name-contact').value){ alert('Name cannot be blank.'); document.getElementById('name').focus(); return false; } if(!checkEmail(document.getElementById('email-contact').value)){ alert('Incorrect Email'); document.getElementById('email').focus(); return false; } if('' == document.getElementById('comment-contact').value){ alert('Comment cannot be blank.'); document.getElementById('comment').focus(); return false; } if('' == document.getElementById('verification').value){ alert('Verification cannot be blank.'); document.getElementById('verification').focus(); return false; } }