This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
function formatCurrency() | |
{ | |
// Get the values from the text-boxes | |
var symbol = document.getElementById('formatCurrencySymbol').value; | |
var number = parseFloat(document.getElementById('formatCurrencyNumber').value); | |
var decimalPlaces = document.getElementById('formatCurrencyDecimalPlaces').value; | |
// Do the formatting - Regex here! | |
var result = symbol + number.toFixed(decimalPlaces).replace(/(\d)(?=(\d{3})+\.)/g, "$1,"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
// This function will allow 0123456789, left, right, and backspace on a textbox | |
// Use onkeypress="return isNumericKeyPress(event.keyCode);" to trigger | |
function isNumericKeyPress(keyCode) | |
{ | |
return (keyCode >= 48 && keyCode <= 57 || keyCode === 8); | |
} | |
// This function will clear non-numeric values on a textbox when pasted | |
// Use onpaste="isNumericPaste(this);" to trigger |
NewerOlder