﻿// JScript File

function maskKeyPress(objEvent,content,allowedLength,ID) 
	{	   
		if(content.length<=allowedLength)
		{
		    return true;
		}	
        else
    	{
    		alert('You cannot enter more than ' + allowedLength + ' characters');
    		document.getElementById(ID).value = content.substring(0,allowedLength);
    		return false;
    	}
    	
    }
    function Trim(s) 
	{
		// Remove leading spaces and carriage returns
		while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
		{ s = s.substring(1,s.length); }

		// Remove trailing spaces and carriage returns
		while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
		{ s = s.substring(0,s.length-1); }
			
		return s;
	}	 
	function textCounter(fieldControl,cntName,maxlimit) 
    {
        if(fieldControl.value.length>maxlimit)
        {
            fieldControl.value = fieldControl.value.substring(0, maxlimit);
        }
        else
        {
            document.getElementById(cntName).value= fieldControl.value.length;
        }
    } 
    function NumericMask(objEvent,num,allowDecimal) 
    {
	var iKeyCode, strKey;  				
	if (isIE) {
		iKeyCode = objEvent.keyCode;
	} else {
		iKeyCode = objEvent.which;
	}
	
	
	
	strKey = String.fromCharCode(iKeyCode);
	
	
	if(allowDecimal==0)
	{
		DecExists=0;
	}
	else	
	{
		DecExists=num.indexOf('.');
	}
	
	if(iKeyCode!=8)//Backspace
	{
		
    	if((iKeyCode>=48 && iKeyCode<=57) || (iKeyCode==46 && DecExists==-1)||iKeyCode==0)
    	{
        	//Valid Characters;Do nothing
    	}
    	else
    	{
    		return false;
    	}
	}
	return true;
    }
   
    function isNumeric(value)
     {
  if (value == null || !value.toString().match(/^[-]?\d*\.?\d*$/)) return false;
  return true;
}
function checkNum(objEvent,content,allowedLength,ID) 
	{	   
		if(content.length<=allowedLength)
		{
		    return true;
		}	
        else
    	{
    		alert('You cannot enter more than ' + allowedLength + ' digits');
    		document.getElementById(ID).value = content.substring(0,allowedLength);
    		return false;
    	}
    	
    }
