﻿// JScript File

        
        function Trim(str)

{

    while (str.substring(0,1) == ' ') // check for white spaces from beginning

    {

        str = str.substring(1, str.length);

    }

    while (str.substring(str.length-1, str.length) == ' ') // check white space from end

    {

        str = str.substring(0,str.length-1);

    }

   

    return str;

}
function numericvalidation(e,field)
{     
    if (!(((e.keyCode>=48)&&(e.keyCode<=57))))     
    {       
        //alert("Only Digits Are Allowed!");       
        e.keyCode=0;
    }          
    
} 
function floatvalidation(e,field)
{     
    if (!(((e.keyCode>=48)&&(e.keyCode<=57))||(e.keyCode==46)))     
    {       
        //alert("Only Digits Are Allowed!");       
        e.keyCode=0;
    }          
    if (e.keyCode==46)     
    {        
        var patt1=new RegExp("\\.");                
        var ch =patt1.exec(field);               
        if(ch==".")        
        {            
            ///alert("More then one decimal point not allowed");            
            e.keyCode=0;        
        }                             
    }    
} 
function addCurrencyFormat(nStr)
{
    nStr=nStr.toString().replace(/\$|\,/g,'');
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return '$' + x1 + x2;
}


