jsUtils.isMoney()

Checks if the variable is an number compatible with money format.

jsUtils.isMoney( str )
  str - any javascript variable

Returns true if the variable is in money format or false otherwise.

Any input variable is treated as a string. The function will test if the variable is a float number with an exception that it can contain a dollar sign ($) and commas as separators. Dollar sign and commas need to be removed when inserting into a database table.

Example

<!DOCTYPE html>
<html>
<head>
    <script src="system/libs/jsUtils.js" type="text/javascript"></script>
    <script type="text/javascript">
        window.onload = function() {
            alert(jsUtils.isMoney('10.44'));
            alert(jsUtils.isMoney('$100,203.24'));
        }
    </script>
<body>
</body>
</html>

See Also