
function validate() {
	var re = /\S+@\S+\.\S+/;
	var firstname = document.getElementById('fname').value;
	var lastname = document.getElementById('lname').value;
	var sub = document.getElementById('subject').value;

	var em = document.getElementById('e-mail').value;

	var comment=document.getElementById('comment').value;

	submit = true;

	if (firstname == '') {
		document.getElementById('fname_error').innerHTML = "First Name Is Required";
		fname.blur();
		return false;
	}

	if (lastname == '') {
		document.getElementById('lname_error').innerHTML = "Last Name Is Required";
		lname.blur();
		return false;
	}
	if (sub == '') {
		document.getElementById('subject_error').innerHTML = "Subject Is Required";
		subject.blur();
		return false;
	}
	if (em == '') {
		document.getElementById('e-mail_error').innerHTML = "Email Is Required";
		e - mail.blur();
		return false;
	}
	if(comment=='')
	{
		document.getElementById('comment_error').innerHTML = "Comment Is Required";
		return false;
	}

	if (em != '') {
		if (!(re.test(em))) {

			document.getElementById('e-mail_error').innerHTML = "Email Is INVALID!";
			return false;
		}
	}
	return submit;
}

function removewarning(e) {
	var y = e.target;
	var m = y.id + '_error';
	var n = document.getElementById(m);
	n.innerHTML = "";
}



function reset(){


	document.getElementById('fname').value = "";
	document.getElementById('lname').value = "";
	document.getElementById('subject').value = "";
	document.getElementById('e-mail').value= "";
	document.getElementById('comment').value = "";


}
@@ -204,25 +204,24 @@
 ct').value;%0A
-%0A
 %09var em = do
@@ -259,17 +259,16 @@
 .value;%0A
-%0A
 %09var com
@@ -320,21 +320,183 @@
 ;%0A%0A%09
+var 
 submit
- = true
+=false;%0A%09//Trim first and last spaces from all values%0A%09firstname=firstname.trim();%0A%09lastname=lastname.trim();%0A%09sub=sub.trim();%0A%09em=em.trim();%0A%09comment=comment.trim()
 ;%0A%0A%09
@@ -607,32 +607,34 @@
 fname.blur();%0A%09%09
+//
 return false;%0A%09%7D
@@ -746,32 +746,34 @@
 lname.blur();%0A%09%09
+//
 return false;%0A%09%7D
@@ -881,32 +881,34 @@
 bject.blur();%0A%09%09
+//
 return false;%0A%09%7D
@@ -1007,11 +1007,9 @@
 %0A%09%09e
- - 
+-
 mail
@@ -1015,24 +1015,26 @@
 l.blur();%0A%09%09
+//
 return false
@@ -1138,16 +1138,36 @@
 red%22;%0A%09%09
+comment.blur();%0A%09%09//
 return f
@@ -1301,28 +1301,74 @@
 %0A%09%09%09
-return false;%0A%09%09%7D%0A%09%7D
+e-mail.blur();%0A%09%09%09//return false;%0A%09%09%7D%0A%09%7D%0A%09else%7B%0A%09%09submit=true;%0A%09%7D%0A
 %0A%09re
@@ -1535,18 +1535,16 @@
 eset()%7B%0A
-%0A%0A
 %09documen
@@ -1769,11 +1769,72 @@
 e = %22%22;%0A
-%0A
+%7D%0A%0Afunction sendMail()%0A%7B%0A%09var res=validate();%0A    alert(res); 
 %0A%7D

Check spaces as input in Contact