我有一个具有此模型的 ASP.NET MVC2 项目:
[DisplayName("Valor(%)")]
[Required(ErrorMessage = "Este dato es requerido")]
public decimal HOJ_ATI_CONT_SAPO_VALOR1 { get; set; }
[DisplayName("Valor(%)")]
public decimal HOJ_ATI_CONT_SAPO_VALOR2 { get; set; }
看法:
Html.EnableClientValidation();
以及输出客户端验证:
{
"FieldName": "HOJ_ATI_CONT_SAPO_VALOR1",
"ReplaceValidationMessageContents": true,
"ValidationMessageId": "HOJ_ATI_CONT_SAPO_VALOR1_validationMessage",
"ValidationRules": [
{
"ErrorMessage": "Este dato es requerido",
"ValidationParameters": {},
"ValidationType": "required"
},
{
"ErrorMessage": "The field Valor(%) must be a number.",
"ValidationParameters": {},
"ValidationType": "number"
}
]
},
{
"FieldName": "HOJ_ATI_CONT_SAPO_VALOR2",
"ReplaceValidationMessageContents": true,
"ValidationMessageId": "HOJ_ATI_CONT_SAPO_VALOR2_validationMessage",
"ValidationRules": [
{
"ErrorMessage": "The Valor(%) field is required.",
"ValidationParameters": {},
"ValidationType": "required"
},
{
"ErrorMessage": "The field Valor(%) must be a number.",
"ValidationParameters": {},
"ValidationType": "number"
}
]
}
为什么十进制字段添加默认的必需属性?我需要删除所需的验证类型。