0
Model類後的不同HTML:剃刀生成發佈到共享主機
public class MyClass
{
......
[MaxLength(9), Required, DisplayName("Social security number")]
[RegularExpression(@"\d{3}-\d\d-\d{4}", ErrorMessage = "Invalid social security number")]
public string SocialSecurityNumber { get; set; }
}
剃刀:在Visual Studio 2012 /鉻運行時
@Html.TextBoxFor(model => model.SocialSecurityNumber, new { id = "ssn" })
@Html.ValidationMessageFor(model => model.SocialSecurityNumber)
生成的代碼。
<input data-val="true"
data-val-regex="Invalid social security number"
data-val-regex-pattern="\d{3}-\d\d-\d{4}"
data-val-required="The Social security number field is required."
id="ssn"
name="SocialSecurityNumber"
type="text"
value=""
class="input-validation-error">
<span
class="field-validation-error"
data-valmsg-for="SocialSecurityNumber"
data-valmsg-replace="true">
<span for="ssn" class="" style="">Invalid social security number</span>
</span>
發佈到共享主機
<input
data-val="true"
data-val-regex="Invalid social security number"
data-val-regex-pattern="\d{3}-\d\d-\d{4}"
data-val-required="The Social security number field is required."
id="ssn"
name="SocialSecurityNumber"
type="text"
value="">
<span
class="field-validation-valid"
data-valmsg-for="SocialSecurityNumber"
data-valmsg-replace="true"></span>
爲什麼通過VS運行網站有更多的生成的html代碼後
生成的代碼? (class="input-validation-error">
等 )
您是否收到託管網站上的驗證錯誤? –