Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

How can I limit the text input only to allow English characters and numbers?

$
0
0

These days I am working hard on blazor server-side for validation.

Here are my codes:

public class ModelClass {
[Required]
public string Code { get; set; }
}
public ModelClass Model { get; set; } = new ModelClass();
private void HandleValidSubmit()
{
//
}

<EditForm Model="@Model " OnValidSubmit="HandleValidSubmit">
<DataAnnotationsValidator />
<ValidationSummary />
<InputText id="input_text" @bind-Value="Model.Code" />
<input type="submit" class="input_submit" value="Continue" />
</EditForm>

The Required attribute is used to limit the text input is not null. Now I want to limit the text input only to allow English characters and numbers.

It seems there are not any other attributes that can do it. How can I solve this? Thank you.


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>