var whspace = " \t\n\r";
	/**This is funtion remove the white space for given string
           And return string
        */
	function removeWhitespace (s)
	{
		var i;
		var finalstr="";
		// Search through string's characters one by one
 	   	// until we find a white space character.
 	   	// When we do,elements the white space and  return  the string ; if we don't, return string.
 	   	for (i = 0; i < s.length; i++)
 	   	{   
			
       		// Check that current character isn't white space.
			//remove the white space and append the valid characters only
       		var c = s.charAt(i);
			if (!(whspace.indexOf(c) == 0  || whspace.indexOf(c) == 1 || whspace.indexOf(c) == 3 )) 
			{
				finalstr+=s.charAt(i);
			}
	   	}
		// No characters are whitespace.
		return finalstr;
 	}
	/**This is funtion check for alphabets
           And return true if the supplied string is not alphabets
        */
	function  isNotAlphabets(str,alpha)
	{
		//calling removeWhitespase function to remove white space
		var i;
		//checking for Alphabets characters
		if(str.length==0 || str==null)
		{
			return true;
		}
	    	// Search through string's characters one by one.
	    	// If character is aplhabets
	    	for (i = 0; i < str.length; i++)
   		{   
        		// Check that current character isn't whitespace.
        		var c = str.charAt(i);
       			if (alpha.indexOf(c) == -1) return true;
    		}
    		return false;
  	}
	/**This function is to check for correct e-mail id.
           And return false if not correct emailId format
        */
	function isEmail(s)
        {
		   s=removeWhitespace(s);
		   //checking for Alphabets characters
		   if(s.length==0 || s==null)
		   {
				return false;
		   }
           // there must be >= 1 character before @, so we
           // start looking at character position 1
           // (i.e. second character)
           var i = 1;
           var sLength = s.length;

           // look for @
           while ((i < sLength) && (s.charAt(i) != "@"))
           { 
				i++
           }
           if ((i >= sLength) || (s.charAt(i) != "@")) return false;
           else i += 2;
 
           // look for .
           while ((i < sLength) && (s.charAt(i) != "."))
           {	
				i++
           }
           // there must be at least one character after the .
           if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
           else return true;
        }
	/** This function do the validation
            And check the following condition
            1.checking alphabets
            2.checking passwards are correct
            3.checking for correct emailid format
            And return true
        */
	function validate()
	{
		var v1,v2,v3,v4;
		//get all the form values
		v1=document.user_registration.user_id.value.toLowerCase();
		v2=document.user_registration.password.value;
		v3=document.user_registration.con_password.value;
		v4=document.user_registration.e_mail.value;
		if(isNotAlphabets(v1,"abcdefghijklmnopqrstuvwxyz0123456789_"))
		{
			alert("Enter AlphaNumeric characters for UserId");
			document.user_registration.user_id.value="";
			document.user_registration.user_id.focus();
			return false;
		}
		if(v2!=v3)
		{
			alert("Password and Confirm password value is not same");
			document.user_registration.con_password.value="";
			document.user_registration.con_password.focus();
			return false;
		}
		if(isNotAlphabets(v2.toLowerCase(),"abcdefghijklmnopqrstuvwxyz0123456789_"))
		{
			alert("Enter AlphaNumeric characters for Password");
			document.user_registration.password.value="";
			document.user_registration.password.focus();
			return false;
		}
		if(isNotAlphabets(v3.toLowerCase(),"abcdefghijklmnopqrstuvwxyz0123456789_"))
		{
			alert("Enter AlphaNumeric characters for Confirm Password");
			document.user_registration.con_password.value="";
			document.user_registration.con_password.focus();
			return false;
		}
		if(!isEmail(v4))
		{
				alert("Enter your Correct E-Mail Id");
				document.user_registration.e_mail.value="";
				document.user_registration.e_mail.focus();
				return false;
		}
	return true;
	}