Search code examples
devexpress-wpf

RegEx validation inTextEdit control of DevExpress


I need to restrict user input in a text edit control to 1-99. After reading this ticket https://www.devexpress.com/Support/Center/Question/Details/Q458791, used a RegEx mask to achieve it.

<dxe:TextEdit Grid.Column="2" Text="{Binding FontSize , UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Grid.Row="1"  VerticalAlignment="Center" MaskType="RegEx" MaskUseAsDisplayFormat="True" Mask="^[1-9]\d?$" EditValueChanged="TextEdit_EditValueChanged"/>

Now its showing the mask string as well in the input area (^[1-9]\d?$). Tried with different reg ex combinations. Please help.


Solution

  • ^ and $ usually marks the beginning and the end of a string in a regex filtered mask. In these text editors, the input is always counted as a string. You don't need to do this by yourself.

    If you would search in a text for a specific combination, you will need to use ^ and $.