-2

我正在使用accounting.js,我需要动态格式化值。

  $('#<%=txtamount1.ClientID %>').bind('keydown keyup keypress focus blur paste change', function () {

                        result = accounting.formatMoney(
                                $('#<%=txtamount1.ClientID %>').val(),
                                '',
                                2,
                                ","
                            );
                        $('#<%=txtamount.ClientID %>').val(result);

                    });
4

1 回答 1

0
 $(document).ready(function () {
            $('#txtamount1').live('keyup change', function (e) {
                $(this).val(function () {
                    return accounting.formatMoney(($(this).val()+ String.fromCharCode(e.keyCode)), '', 2, ",");
                });
            });

            $('#txtamount1').trigger('keyup');
 });​

对于现场演示,请参阅此链接:http: //jsfiddle.net/nanoquantumtech/2s9wQ/

于 2012-05-19T10:14:26.443 回答