2017-02-16 65 views
-2

我試圖與千位分隔符保存號碼字段內數千位分隔符剃刀MVC和JS

1000 >> 1000

100000 >>萬

2000.02 >> 2,000.02

我想在這個問題上使用js和jquery, 我希望在用戶輸入時讓數千個分隔符變得可見。

<div class="form-group"> 
 

 
    <label class="control-label col-md-2" Sum</label> 
 
    <div class="col-md-10"> 
 
    @Html.EditorFor(model => model.Sum, new { htmlAttributes = new { @class = "form-control", @type = "number" } }) 
 
    @Html.ValidationMessageFor(model => model.Sum, "", new { @class = "text-danger" }) 
 
    </div> 
 
</div>

任何幫助嗎?

回答

1

你可以試試autoNumeric插件。基本init將你需要的東西:

$('#Sum').autoNumeric('init'); 

檢查部分:

上獲得autoNumeric()並與初始化 爲 'init' 的方法和默認設置運行的基礎知識:...

+0

我怎樣才能找到最新版本的AutoNumeric?我試圖找到它,但我不能。你有另一個鏈接? @teo – askm

+0

@askm在這個頁面上我們有**兼容jQuery-1.7.2及更高版本**所以有什麼問題? –

+0

謝謝,它的工作原理。 – askm