• Material 3
  • Fluent
  • Fluent 2
  • Bootstrap 5
  • Tailwind CSS
  • High Contrast
  • Fluent 2 High Contrast
Preferences
Mode Selection
Touch
Mouse
Theme Selection
Theme Mode
Localization
*Translated by Google Translator.
Currency

Example of Custom Mask in ASP.NET Core Input Mask Control

This sample demonstrates that the custom mask functionalities of MaskedTextBox component. Enter time value in meridiem format, and enter IP value in numeric format.

DEMO
SOURCE
Time (ex: 10:00 PM, 10:00 AM)
IP Address (ex: 212.212.111.222)

The custom mask is achieved by the following ways:

Custom characters:

You can form the mask with any non-mask elements (literals), and you can configure the behavior of that non-mask element as mask element through the customCharacters property.

In this demo, the “Time” mask '99 : 99 >PM' contains the literals P and M, where it is configured to allow the inputs as 'P', 'A', 'p', 'a', and 'M', 'm'.

Regular expression:

Alternatively, you can use the regular expressions as mask element to validate the input of the particular input place.

Here, in the “IP Address” example, each character is masked by an regular expression to allow a particular range of values.

More information about MaskedTextBox can be found in this documentation section.

Transform your ASP.NET Core web apps today with Syncfusion® ASP.NET Core components
100+ high-performance and responsive UI components
Dedicated support
Hassle-free licensing
TRY IT FOR FREE
opens in a new tab