JSFiddle - React, Tailwind, and code Playground

checkDollars Function

by Jennifer Perrin

HTML

<div id="theval"></div>
<div id="thereturn"></div>

JavaScript

jQuery(function ($) {
  var theval = '999,999,999.99';
	$('#theval').text(theval);
	
	var checkIt = checkDollars(theval);
	$('#thereturn').text(checkIt);
});

function checkDollars(val) {
	var value = val.replace(/,/g, '');
	var x = parseFloat(value).toFixed(2);
	
	if (x.toString().length > 12) {
		return false;
	} else {
		return true;
	}
}