﻿
   
    function trim(s) 
            {
           while (s.substring(0,1) == ' ') 
                {
              s = s.substring(1,s.length);
                }
           while (s.substring(s.length-1,s.length) == ' ') 
             {
             s = s.substring(0,s.length-1);
             }
            return s;
             } 
             
             
        function checkSpecialCharectors(inputText,type) 
	{ 
		var ss2; 
		var ValidChars2;
		
		if(type==1)
			ValidChars2="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_. "; 

		else if (type==2)
			ValidChars2="0123456789";

		else if (type==3)
			ValidChars2="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_@."; 

		else if (type==4)
			ValidChars2="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 "; 

		else if (type==5)
			ValidChars2="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\#-_/"; 

		else if (type==6)
			ValidChars2="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "; 

		else if (type==7)
			ValidChars2="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"; 

		ss2 = inputText; 		
		for(i=0;i<ss2.length;i++) 
			{ 
				Char = ss2.charAt(i); 
				if (ValidChars2.indexOf(Char) == -1) 
					{ 
						return false; 
				    } 
			}
		return true; 
	} 	
	
    function initial_focus()
    {
        document.getElementById("ctl00_txt_userid").focus();            
    }
    
    function chk_frm(frm)
	{

	    if (trim(document.aspnetForm.ctl00_txt_userid.value).length == 0)
		{
		    document.getElementById("ctl00_txt_userid").focus();			
			alert('Please complete UserName !');
			return false;
		}

		else if (!checkSpecialCharectors(document.aspnetForm.ctl00_txt_userid.value, 1))
	    {
	        document.getElementById("ctl00_txt_userid").focus();
			alert('UserName contains invalid characters !');
			return false;
		}
		else if (trim(document.aspnetForm.ctl00_txt_password.value).length == 0)
		{
		    document.getElementById("ctl00_txt_password").focus();
			alert('Please complete Password !');
			return false;
		}

		else if (!checkSpecialCharectors(document.aspnetForm.ctl00_txt_password.value, 1))
	    {
	        document.getElementById("ctl00_txt_password").focus();
			alert('Password contains invalid characters !');
			return false;
		} 

    else		
	    {
		return true;		
	    }
   }		

