c# - Custom ValidationAttribute not Firing On Invalid Data Razor Views -


so have following custom attribute:

public class yearorolderattribute : validationattribute {    protected override validationresult isvalid(object value, validationcontext validationcontext)     {       if (value == null || (int)value <= datetime.now.year)       {          return true;       }        return new validationresult($"year must less {datetime.now.year}"); } 

on view model have following:

[yearorolder(errormessage = "you can't go future!")] public int? yearinput { get; set; } 

on in view have following:

@html.kendo().textboxfor(model => model.yearinput) 

i have jquery -> jquery.validate -> jquery.unobtrusivevalidation on page in order.

the custom attribute hit after form submitted, not on blur. if basic '[range(1234, 4321)]' attribute, triggers fine , error message shows. why isn't custom attribute being triggered?


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -