// JavaScript Document
//*============================================================================================#*/ 
//* Function for adding a Filter to an Input Field                                             #*/ 
//* : [filterInputType  ] Type of filter 0=>Alpha, 1=>Num, 2=>AlphaNum                         #*/ 
//* : [evnt      ] The Event Object                                                            #*/ 
//* : [setDecimal] To allow Decimal Point set this to true                                     #*/ 
//* : [setCustom ] Custom Characters that are to be allowed ==this is ditermind at the calling #*/
//*                  page                                                                       */   
//==============================================================================================*/ 
function filterInput(filterInputType, evt, allowDecimal, allowCustom){ 

    var keyCode, Char, inputField, filter = ''; 
    var alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '; 
    var num   = '0123456789'; 
    // Get the Key Code of the Key pressed if possible else - allow 
    if(window.event){ 
        keyCode = window.event.keyCode; 
        evt = window.event; 
    }else if (evt)keyCode = evt.which; 
    else return true; 
    // Setup the allowed Character Set 
    if(filterInputType == 0) filter = alpha; 
    else if(filterInputType == 1) filter = num; 
    else if(filterInputType == 2) filter = alpha + num; 
    if(allowCustom)filter += allowCustom; 
    if(filter == '')return true; 
	
    // Get the Element that triggered the Event 
    inputField = evt.srcElement ? evt.srcElement : evt.target || evt.currentTarget; 
    // If the Key Pressed is a CTRL key like Esc, Enter, Home etc - allow 
    if((keyCode==null) || (keyCode==0) || (keyCode==8) || (keyCode==9) || (keyCode==13) || (keyCode==27) )return true; 
    // Get the Pressed Character 

    Char = String.fromCharCode(keyCode); 
	
    // If the Character is a number - allow 
	//alert(Char);
	//alert(filter.indexOf(Char));
    if((filter.indexOf(Char) > -1))
		{
		return true; 
		}
     //Else if Decimal Point is allowed and the Character is '.' - allow 
    else if(filterInputType == 1 && allowDecimal && (Char == '.') && inputField.value.indexOf('.') == -1)
	{return true;}
    else
	{return false;}
		
	
}
function check_textfield_maxlength(obj){
var field_textfield_mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : "";
if (obj.getAttribute && obj.value.length==field_textfield_mlength)
   {
    obj.value=obj.value.substring(0,field_textfield_mlength);
	alert("Text has reached the maximum limit");
   }
}

var alphanumeric = "`~!@#-_=|]}[{:/?.,";
alphanumeric += " \ ";
//This function is to reset the input field to be space



function checkmaxlength(obj){

var field_mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : "";
if (obj.getAttribute && obj.value.length>field_mlength)
   {
    obj.value=obj.value.substring(0,field_mlength);
	alert("Text has reached the maximum limit");
   }
  //return filterInput(2, event, false, '@_-,/.');
}


function check_textfield_maxlength(obj){

var field_textfield_mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : "";
if (obj.getAttribute && obj.value.length==field_textfield_mlength)
   {
    obj.value=obj.value.substring(0,field_textfield_mlength);
	alert("Text has reached the maximum limit");
   }
}

function OnPaste () 
{
   return false;   // cancels the onpaste event
	
}


