function cleanUp(number) {
    re = /^\$|,/g;
    return number.replace(re, ""); // remove "$" and ","
}

//Function used by the CurrencyValidator for client-side validation
function validateCurrency(sender, args) {
	var input = $('#'+sender.controltovalidate).val();
	
	if(!input){
		// No input - this is allowed
		args.IsValid = true;
		return;
	}

	// Check for currency formatting.
	// Expression is from http://regexlib.com/REDetails.aspx?regexp_id=70
	re = /^\$?([0-9]{1,3},([0-9]{3},)*[0-9]{3}|[0-9]+)(\.[0-9][0-9])?$/;
	isCurrency = input.match(re);

	if (isCurrency) {
		// Convert the string to a number.
		var number = parseFloat(cleanUp(input));
		if (number != NaN) {
			// Check the range.
			//Extract the value from the attributes on the validator
			var min = $(sender).attr('minValue');
			var max = $(sender).attr('maxValue');
			if (min <= number && max >= number) {
				// Input is valid.
				args.IsValid = true;
				return;
			}
		}
	}

	// Input is not valid if we reach this point.
	args.IsValid = false;
	return;

}

