我正在使用以下代码在印度编号系统中显示货币:
<script type="text/javascript">
function format(obj) {
var formatted = obj.value.replace(/\D/g, '');
obj.value = formatted.replace(/(\d+)(\d{2})/g,'$1.$2');
}
</script>
<input type="number" onkeyup="format(this)">
我得到的输出:123456.78
我想要的输出是:1,23,45,678.00
请帮助!
答案 0 :(得分:1)
您可以使用gif2
const number = 12345678;
console.log(new Intl.NumberFormat('en-IN').format(number));
如果该货币应该是货币,则可以将其作为第二个参数传递
const number = 12345678;
console.log(new Intl.NumberFormat('en-IN', {style: 'currency', currency: 'INR'}).format(number));
或强制使用两位小数:
const number = 12345678;
console.log(new Intl.NumberFormat('en-IN', {minimumFractionDigits: 2}).format(number));
答案 1 :(得分:0)
Number.prototype.toLocaleString()在这里将有很大帮助。
SqlCommand insert = new SqlCommand();
insert.Connection = conn2; // conn2 is the connection of the second database
insert.Parameters.Add("@Réf", SqlDbType.Int).Value = row["N° Caisse"];// row is a row of a datagrid
insert.CommandText = "INSERT INTO Caisse([N° Caisse], [Date d'Ouverture], [Date de Clôture], [Fond de Caisse], [Vendeur]) SELECT * FROM Database1.Caisse WHERE Databse1.Caisse.[N° Caisse] = @Réf";
// notice that both database have a table named "Caisse" so I'm inserting into 'Caisse of the second database the records selected from "Caisse" of the first table
conn2.Open();
insert.ExecuteNonQuery();
conn2.Close();