@if (ViewData.ModelMetadata.ModelType.IsNumeric()) { <input type="number" id=@ViewData.ModelMetadata.PropertyName name=@ViewData.ModelMetadata.PropertyName class="numericOnly" value=@Model /> } else { @Html.TextBox("", (object)Model, new Dictionary<string, object> { { "id", ViewData.ModelMetadata.PropertyName }, { "name", ViewData.ModelMetadata.PropertyName }, { "class", "text-box single-line"}, { "data-bind", "value: " + ViewData.ModelMetadata.PropertyName }, }) }where IsNumeric was an extension method based on the last message in this thread