我怎樣才能美元符號添加到MVC值
@Html.TextBoxFor(x => x.RefundAmount, new { @class = "form-control", id = "RefundAmount", name = "RefundAmount",disabled="disabled" })
我怎樣才能美元符號添加到MVC值
@Html.TextBoxFor(x => x.RefundAmount, new { @class = "form-control", id = "RefundAmount", name = "RefundAmount",disabled="disabled" })
@Html.TextBoxFor(x => "$"+x.RefundAmount, new { @class = "form-control", id = "RefundAmount", name = "RefundAmount",disabled="disabled" })
試試這個上面的代碼
它不起作用 – ArunRaju
您的帖子不清楚。請解釋清楚 –
如果您確信它會是HTML5功能的瀏覽器,您可以使用模式屬性。
pattern="^\\$?(([1-9](\\d*|\\d{0,2}(,\\d{3})*))|0)(\\.\\d{1,2})?$"
@Html.TextBoxFor(model => model.RefundAmount, new { @class = "required numeric", Value=String.Format("$ {0}",Model.RefundAmount) })
試試這個
如果你想添加'$'符號? –
之前在文本框中的值 – ArunRaju
這取決於你想要做什麼..如果你想要'$'不應該被刪除的貨幣格式,然後把它放在文本框外作爲一個簡單的解決方案。如果它只是您想要顯示的文本,您可以簡單地在文本框中顯示的文本前附加'$'。 –