The RemoteAttribute depends on jQuery via the unobtrusive ajax library. There is nothing comparable in Blazor. You just need to wire up an event handler to the onchange event of an input that calls a service to perform validation as required. Something like
this:
Thank you for the reply (and the bad news ), @Mikesdotnetting! Obviously not a cool as adding an attribute and allowing things to "just work" but it will put me in the right direction. I will probably encapsulate it in a component and use that instead.
Blazor uses data attribute validation, so you can create your own custom validators. But currently there is no async validation, so they should not be used for remote validation.
Member
13 Points
64 Posts
RemoteAttribute?
Aug 13, 2020 06:55 AM|MichaelDBang|LINK
Looking to do this:
https://stackoverflow.com/questions/54186153/remote-validation-in-asp-net-core-razor-pages
But in Blazor Server-side, and preferably without JQuery.
Possible?
All-Star
194882 Points
28101 Posts
Moderator
Re: RemoteAttribute?
Aug 17, 2020 02:56 PM|Mikesdotnetting|LINK
The RemoteAttribute depends on jQuery via the unobtrusive ajax library. There is nothing comparable in Blazor. You just need to wire up an event handler to the onchange event of an input that calls a service to perform validation as required. Something like this:
The method at api/email/validate will contain the logic that ensures the value is valid, returning a bool either way.
Member
13 Points
64 Posts
Re: RemoteAttribute?
Aug 17, 2020 03:13 PM|MichaelDBang|LINK
Thank you for the reply (and the bad news ), @Mikesdotnetting! Obviously not a cool as adding an attribute and allowing things to "just work" but it will put me in the right direction. I will probably encapsulate it in a component and use that instead.
All-Star
58484 Points
15806 Posts
Re: RemoteAttribute?
Aug 17, 2020 07:49 PM|bruce (sqlwork.com)|LINK
Blazor uses data attribute validation, so you can create your own custom validators. But currently there is no async validation, so they should not be used for remote validation.