Blazor Edit Form and Validation

     For a class project I'm working on in a secure coding class I wanted to find a way to safely validate form data as to not send malicious values to our API or our database. I was working out how to do this in Blazor, and found the handy EditForm component. It allows you to enter a type of model you'd like the form to build, and in that model we can specify if the form is required and what type of data is allowed in.

 

    In this example we have a couple required fields and we don't allow any special characters into our fields. We also only allow a certain length of string as our input, and simple error messages are displayed when invalid data is passed. When proper or improper data is passed to our form, it looks like this:

 

Comments

Popular posts from this blog

API's in C#

Using WebRTC to build a videophone in React and TypeScript

Reviewing WPF and MVVM