
function validate() {
var str = 'Please enter the following ' ;

id1=document.insert.username.value ;
if (id1=='') 
{
str = str + 'username '
event.returnValue=false;
}


id1=document.insert.fname.value ;
if (id1=='') 
{
str = str + 'fullname '
event.returnValue=false;
}

id1=document.insert.addr1.value ;
if (id1=='') 
{
str = str + 'address line 1 '
event.returnValue=false;
}

id1=document.insert.city.value ;
if (id1=='') 
{
str = str + 'city '
event.returnValue=false;
}

id1=document.insert.zip.value ;
if (id1=='') 
{
str = str + 'zip code '
event.returnValue=false;
}

id1=document.insert.phone.value ;
if (id1=='') 
{
str = str + 'phone number '
event.returnValue=false;
}

id1=document.insert.email.value ;
if (id1=='') 
{
str = str + 'email '
event.returnValue=false;
}

var invalid = " "; // Invalid character is a space
if (document.insert.username.value.indexOf(invalid) > -1) {
	
str = str + '. Spaces in username are not allowed'
event.returnValue=false;
}  

var invalid = " "; // Invalid character is a space
if (document.insert.pwd.value.indexOf(invalid) > -1) {
	
str = str + '. Spaces in password are not allowed'
event.returnValue=false;
} 

var invalid = " "; // Invalid character is a space
if (document.insert.pwd1.value.indexOf(invalid) > -1) {
	
str = str + '. Spaces in repeat password are not allowed'
event.returnValue=false;
}  

var invalid = " "; // Invalid character is a space
if (document.insert.email.value.indexOf(invalid) > -1) {
str = str + '. Spaces in email address are not allowed'
event.returnValue=false;
} 

if (document.insert.pwd.value != document.insert.pwd1.value) {
	str = str + '. Password and repeat password values are not the same'
	event.returnValue=false;
}

if (document.insert.pwd.value.length <7 ) {
	str = str + '. Password should be atleast 7 characters'
	event.returnValue=false;
}

var x = document.forms[0].username.value;
	var filter  = /^([a-zA-Z0-9])/;
	if (filter.test(x)) 
	;
	else 
	{
	str = str + '. Username should contain alphabets and numbers only';
	event.returnValue=false;
	}
	
	var x = document.forms[0].pwd.value;
	var filter  = /^([a-zA-Z0-9])/;
	if (filter.test(x)) 
	;
	else 
	{
	str = str + '. Password should contain alphabets and numbers only.';
	event.returnValue=false;
	}

var x = document.forms[0].email.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) 
	;
	else 
	{
	str = str + '. Email Address is invalid.';
	event.returnValue=false;
	}
	
if ((!IsNumeric(document.insert.zip.value)) || (!IsNumeric(document.insert.phone.value)) ) 
   { 
      str = str + '. Please enter only numbers for zip code and Phone Number' ;
      document.insert.zip.focus(); 
      event.returnValue=false;
   }
          
if (event.returnValue==false)
	alert(str)
}
	