0
如果你看一看this bootstrap documentation爲formhelpers,我可以用如何在@ Html.TextBoxFor中使用bootstrap-formhelpers數據格式?
<input type="text" class="form-control bfh-phone" data-format="+1 (ddd) ddd-dddd" placeholder="Cell or Home Phone" required>
當用戶輸入一個電話號碼,格式化文本框。我想用@Html.TextBoxFor
或@Html.EditorFor
來做同樣的事情。我如何在mvc中完成此操作?這是我曾嘗試:
<input type="text" class="form-control bfh-phone" data-format="+1 (ddd) ddd-dddd" value="@Model.PhoneNumber" placeholder="Cell or Home Phone" required>
和
@Html.EditorFor(model => model.PhoneNumber, new { htmlAttributes = new { @class = "form-control bfh-phone", @placeholder = "Cell or Home Phone", @data-format="+1 (ddd) ddd-dddd" } })
這兩者給出了object reference
剃刀語法錯誤。這是如何完成的?