mvc 中隐藏字段的远程验证不会被触发 Model :
[Remote("checker", "mycontroller", ErrorMessage = "Valid combination of phone and account number required.", HttpMethod = "Get")]
public string Validate_cart { get; set; }
看法 :
@Html.HiddenFor(model => model.Validate_Paris)
还尝试使用 jquery 设置值:
$("#Phone_Number").blur(function () {
$("#Validate_cart").val = "dummy"
});
使用 jquery 或按模型设置值,但不会触发验证。我使用提琴手检查过,任何时候都没有调用该方法。
方法
[HttpGet]
public bool checker(string Validate_cart )
{
try
{
bool isValid = //code to hit database to check the record
return !isValid;
}
catch (Exception)
{
throw;
}
}