/*
  -------------------------------------------------------------------------
	                    JavaScript Form Validator 
                                Version 2.0.2
	Copyright 2007 Pipal infotech Pvt Ltd. All rights reserved.
	You use this script in your Web pages, provided these opening credit
    lines are kept intact.
	The Form validation script is distributed free from Pipal infotech Pvt Ltd.

	You may please add a link to Pipal infotech Pvt Ltd, 
	making it easy for others to find this script.
	Checkout the Give a link and Get a link page:
	
    You may not reprint or redistribute this code without permission from 
    	
	Pipal infotech Pvt Ltd.
	http://pipalweb.com/
	
    -------------------------------------------------------------------------  
*/


function ValidateTextBox(xobj,fieldName)
    {      
      
       var prefixObj = xobj.id;
       prefixObj = prefixObj.substring(0,3);
       
       var xobjLen = Trim(xobj.value);
       if (xobjLen.length == 0)
       {
           alert(fieldName + " is Mandatory");
           xobj.focus()
           xobj.value = ""; 
           return 1;
       }
           return 0;
    }

function pwdMatchTest(textObj_1,textObj_2,fieldName1,fieldName2)
    {
    
    if (textObj_1 != textObj_2)
    {
        alert(fieldName1 + " And " + fieldName2 + " Are Not Same");
        textObj_1.focus()
        textObj_1.value = ""; 
        textObj_2.value = ""; 
        return 1;
    }
        return 0;
    }

function checkAlphaNuemeric(txtObj,fieldName)
    {
         //debugger;   
       var strTextObj = txtObj.value;     
       var code=new Array(strTextObj.length);
       for(var i=0;i<strTextObj.length;i++)
       {
            code[i]=strTextObj.charCodeAt(i);
            
            if (((code[i] >= 65) && (code[i] <= 90)) || ((code[i] >= 97) && (code[i] <=122)) || ((code[i] >= 48) && (code[i] <= 57)))
            {
            }
            else
            {
             alert("In " + fieldName + " Invalid character Entered");
             txtObj.focus()
             txtObj.value = ""; 
             return 1;
            }
       } 
       return 0;        
    }
function checkAlphaNuemericAndUnderScore(txtObj,fieldName)
    {
         //debugger;   
       var strTextObj = txtObj.value;     
       var code=new Array(strTextObj.length);
       for(var i=0;i<strTextObj.length;i++)
       {
            code[i]=strTextObj.charCodeAt(i);
            //alert(code[i]);
            if (((code[i] >= 65) && (code[i] <= 90)) || ((code[i] >= 97) && (code[i] <=122)) || ((code[i] >= 48) && (code[i] <= 57) ||(code[i] == 95) ))
            {
            }
            else
            {
             alert("In " + fieldName + " Invalid character Entered");
             txtObj.focus()
             txtObj.value = ""; 
             return 1;
            }
       } 
       return 0;        
    }
function checkNumbers(txtObj,fieldName)
    {
       var strTextObj = txtObj.value;     
       var code=new Array(strTextObj.length);
       for(var i=0;i<strTextObj.length;i++)
       {
            code[i]=strTextObj.charCodeAt(i);
            
            if (((code[i] >= 48) && (code[i] <= 57)))
            {
            }
            else
            {
             alert("In " + fieldName + " Invalid character Entered");
             txtObj.focus()
             txtObj.value = ""; 
             return 1;
            }
       } 
       return 0;        
    }
    
    
function checkNames(txtObj,fieldName)
    {
      
       var strTextObj = txtObj.value;     
       var code=new Array(strTextObj.length);
       for(var i=0;i<strTextObj.length;i++)
       {
            code[i]=strTextObj.charCodeAt(i);
            
            if (((code[i] >= 65) && (code[i] <= 90)) || ((code[i] >= 97) && (code[i] <=122)) || (code[i] == 32) || (code[i] == 46))
            {
            }
            else
            {
             alert("In " + fieldName + " Invalid character Entered");
             txtObj.focus()
             txtObj.value = ""; 
             return 1;
            }
       } 
       return 0;        
    }
    
    
function checkPhoneNumbers(txtObj,fieldName)
    {
       var strTextObj = txtObj.value;     
       var code=new Array(strTextObj.length);
       for(var i=0;i<strTextObj.length;i++)
       {
            code[i]=strTextObj.charCodeAt(i);
            
            if (((code[i] >= 48) && (code[i] <= 57)) || (code[i] == 43) || (code[i] == 45))
            {
            }
            else
            {
             alert("In " + fieldName + " Invalid character Entered");
             txtObj.focus()
             txtObj.value = ""; 
             return 1;
            }
       } 
       return 0;        
    }

function checkAddressFields(txtObj,fieldName)
    {
       var strTextObj = txtObj.value;     
       var code=new Array(strTextObj.length);
       for(var i=0;i<strTextObj.length;i++)
       {
            code[i]=strTextObj.charCodeAt(i);
            
            if (((code[i] >= 65) && (code[i] <= 90)) || ((code[i] >= 97) && (code[i] <=122)) || ((code[i] >= 48) && (code[i] <= 57)) || (code[i] == 32) || (code[i] == 46) || (code[i] == 47) || (code[i] == 92) || (code[i] == 40) || (code[i] == 41) || (code[i] == 35) || (code[i] == 45))
            {
            }
            else
            {
             alert("In " + fieldName + " Invalid character Entered");
             txtObj.focus()
             txtObj.value = ""; 
             return 1;
            }
       } 
       return 0;        
    }

function stringLengthLimiter(textObj,fieldName,strlength)
    { 
     
       var xobjLen =  textObj.value;
       if (xobjLen.length > strlength)
       {
            alert(fieldName + " Exceeds in Length ");
            textObj.focus()
            textObj.value = ""; 
            return 1;
       }
       return 0;
    }


function Trim(s)
{
       return s.replace(/^\s+|\s+$/g,"");
}

/*
	Copyright 2003 JavaScript-coder.com. All rights reserved.
*/
