Full version: jsB@nk » Utility » Converter » Commas script
URL: https://www.javascriptbank.com/commas-script.html
Quickly add commas to any numerical form input. Great for displaying large numbers!
Full version: jsB@nk » Utility » Converter » Commas script
URL: https://www.javascriptbank.com/commas-script.html
<SCRIPT LANGUAGE="JavaScript">// Mark Henwood ([email protected])<!-- Beginfunction commaSplit(srcNumber) {var txtNumber = '' + srcNumber;if (isNaN(txtNumber) || txtNumber == "") {alert("Oops! That does not appear to be a valid number. Please try again.");fieldName.select();fieldName.focus();}else {var rxSplit = new RegExp('([0-9])([0-9][0-9][0-9][,.])');var arrNumber = txtNumber.split('.');arrNumber[0] += '.';do {arrNumber[0] = arrNumber[0].replace(rxSplit, '$1,$2');} while (rxSplit.test(arrNumber[0]));if (arrNumber.length > 1) {return arrNumber.join('');}else {return arrNumber[0].split('.')[0]; } }}// End --></script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<form name="commas">Input a Number: <input type=text name="inpNumber" size=20 value=""><input type=button value="Add Commas" onClick="document.commas.inpNumber.value=commaSplit(document.commas.inpNumber.value);"></form><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->