0
我在Age元字段中輸入了以下代碼,該元素類型爲int。DataAnnotation範圍驗證程序沒有返回指定的錯誤消息
[Display(Name = "Age", Prompt = "Age")]
[Required(AllowEmptyStrings = false, ErrorMessage = "Age is required")]
[Range(16, 99, ErrorMessage = "Please specify an Age between 16 and 99")]
public int Age { get; set; }
我認爲我已場定義爲:
@Html.TextBoxFor(m => m.Age, new { @class = "form-control numeric", @placeholder = Html.DisplayNameFor(m => m.Age), @type = "number", @min = "16", @max = "99", @maxlength = "2" })
在形式中,HTML呈現爲這樣:
<input name="Age" class="form-control numeric" id="Age" type="number" maxlength="2" min="16" max="99" placeholder="Age" value="" data-val-required="Age is required" data-val-number="The field Age must be a number." data-val="true" data-val-range-min="16" data-val-range-max="99" data-val-range="Please specify an Age between 16 and 99">
然而返回的錯誤消息:
Please enter a value greater than or equal to 16.
hasonon否則之前遇到過這個錯誤?
任何幫助將不勝感激。謝謝。
一些矮人downvotes我,並沒有發表評論的石頭? –