»
AnglaisFran�aisVietnamien

Imprimer - Auto-Mille group?s champs de saisie Nombre - JavaScriptBank.com

Version compl�te: jsB@nk » Form » Textarea » Auto-Mille group?s champs de saisie Nombre
URL: https://www.javascriptbank.com/auto-thousand-grouped-number-input-fields.html

Auto-Mille group?s champs de saisie Nombre © JavaScriptBank.comUn autre exemple de code JavaScript pour cr?er un auto-mille nombre regroup?s apr?s l'arriv?e pour les utilisateurs de type code source JavaScript semble bon et tr?s facile ? utiliser

Version compl�te: jsB@nk » Form » Textarea » Auto-Mille group?s champs de saisie Nombre
URL: https://www.javascriptbank.com/auto-thousand-grouped-number-input-fields.html



JavaScript
<script type="text/javascript">// Created by: Pavel Donchev | http://chameleonbulgaria.com/// This script downloaded from www.JavaScriptBank.comfunction currency(which){currencyValue = which.value;currencyValue = currencyValue.replace(",", "");decimalPos = currencyValue.lastIndexOf(".");if (decimalPos != -1){decimalPos = decimalPos + 1;}if (decimalPos != -1){decimal = currencyValue.substring(decimalPos, currencyValue.length);if (decimal.length > 2){decimal = decimal.substring(0, 2);}if (decimal.length < 2){while(decimal.length < 2){ decimal += "0";}}}if (decimalPos != -1){fullPart = currencyValue.substring(0, decimalPos - 1);} else {fullPart = currencyValue;decimal = "00";}newStr = "";for(i=0; i < fullPart.length; i++){newStr = fullPart.substring(fullPart.length-i-1, fullPart.length - i) + newStr;if (((i+1) % 3 == 0) & ((i+1) > 0)){if ((i+1) < fullPart.length){ newStr = "," + newStr;}}}which.value = newStr + "." + decimal;}function normalize(which){alert("Normal");val = which.value;val = val.replace(",", "");which.value = val;}</script>


HTML
$ <input type="text" name="currencyField1" onchange="currency(this);" />