﻿// JScript File

 function removeCommas( strValue ) {
/************************************************
DESCRIPTION: Removes commas from source string.

PARAMETERS:
  strValue - Source string from which commas will
    be removed;

RETURNS: Source string with commas removed.
*************************************************/
  var objRegExp = /,/g; //search for commas globally

  //replace all matches with empty strings
  return strValue.replace(objRegExp,'');
}
   

function addCommas( strValue ) {
/************************************************
DESCRIPTION: Inserts commas into numeric string.

PARAMETERS:
  strValue - source string containing commas.

RETURNS: String modified with comma grouping if
  source was all numeric, otherwise source is
  returned.

REMARKS: Used with integers or numbers with
  2 or less decimal places.
*************************************************/
  var objRegExp  = new RegExp('(-?[0-9]+)([0-9]{3})');

    //check for match to search criteria
    while(objRegExp.test(strValue)) {
       //replace original string with first group match,
       //a comma, then second group match
       strValue = strValue.replace(objRegExp, '$1,$2');
    }
  return strValue;
}

function chkNumwithcomma(Val)
{
var objExp = /^\$?(\d{1,3},?(\d{3},?)*\d{3}(\.\d{1,3})?|\d{1,3}(\.\d{2})?)$/;
var flag = objExp.test(Val);

if (flag)    
    return "true";
   else
    return "false";
  
}

function chkNum(str,dec)
    {       
   var objExp;
   if (dec=="0")
   {
    objExp=/^\d*$/;
   }
   else
   {
    objExp = /^\d+(\.\d+)?$/;  
   }
 
   var objNumericExp = /^\d*$/;
      
   var flag = objExp.test(str);

  if (flag)    
    return "true";
   else
    return "false";
  
   }

