// JavaScript Document

// JavaScript Document

function checkFormgroups(form){

                 theform=document.frmgrp;

				  if (theform.groupname.value==""){ 

                     alert("Group Name is required")

                     theform.groupname.focus()

                     return false;

                }

				if ((!theform.choose[0].checked) && (!theform.choose[1].checked)){

						alert("Either Zipcode or Country is required!")

						return false;

				}

					if(theform.choose[0].checked){

							if (theform.zipcode.value==""){

							 alert("Zipcode is required!")

							 theform.zipcode.focus()

							 return false;

						}

						

						if (isNaN(theform.zipcode.value)){ 

							 alert("Zipcode must be number!")

							 theform.zipcode.focus()

							 return false;

						}			

						if ((theform.zipcode.value).length<5){ 

							 alert("Zipcode must be five digit number!")

							 theform.zipcode.focus()

							 return false;

						}

				}

				if(theform.choose[1].checked){

							if (theform.country.value==""){

							 alert("Country is required!")

							 theform.country.focus()

							 return false;

						}

							if (!isNaN(theform.country.value)){ 

							 alert("Country should not be number!")

							 theform.country.focus()

							 return false;

						}	

				}	

					if(theform.choose[1].checked){

					 if (theform.city.value==""){ 

                     alert("City is required for this country!")

                     theform.groupcategory.focus()

                     return false;

                }}

                     if (theform.groupcategory.value==""){ 

                     alert(" Choose Groups Category!")

                     theform.groupcategory.focus()

                     return false;

                }

                     if (theform.message_box.value==""){ 

                     alert("Group detail is required!")

                     theform.message_box.focus()

                     return false;

                }

				 

				

                    

     // Check that the form has an email specified in the field called "email"

		var emailaddress = theform.email.value;

		var emailexp = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.(([a-z]{2,3})|(aero|coop|info|museum|name))$/i;

		if (!emailexp.test(emailaddress)) { 

		alert('Email address is missing or invalid, please check your email address')

		theform.email.focus();

		return false;

		}

							

						

		

		<!--

		//Validate Email

		function isEmail(strFieldName,strMsg)

		{

			 var strEmail = strFieldName.value;

			 var bolValid = true;

			 if(strEmail.length == 0){

				  bolValid = false;

			 }

			 if(strEmail.length < 7){

				  bolValid = false;

			 }

			 if(strEmail.lastIndexOf(" ") >0){

				  bolValid = false;

			 }

			 var intLastDot = strEmail.lastIndexOf(".")

			 if(intLastDot == -1 ||  strEmail.length - intLastDot >4){

				  bolValid = false;

			 }

			 var intAt = strEmail.lastIndexOf("@")

			 if(intAt == -1 ||  strEmail.length - intAt < 5){

				  bolValid = false;

			 }

			 if(! bolValid){

				  alert(strMsg.toUpperCase() +" is either empty or is not in the correct format");

					   strFieldName.focus();

					   }

			 return bolValid;

		}

		function validateForm(fObj){

			 if(!isEmail(fObj["email"],"email")){

				  return false;

			 }

			 return true;

		}



}
