We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

SfMaskedEdit not accepting characters after nulling Value when using capture groups

Hi,

I have the following SfMaskedEdit input field:
<syncfusion:SfMaskedEdit x:Name="txtEndTime" Grid.Column="1" Grid.Row="0" Height="26" MaskType="RegEx" Mask="([0-1][0-9]|[2][0-3]):[0-5][0-9]"
                                         Value="{Binding EndTime, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

This RegEx is using a capture group for boolean OR to match time strings like: "12:10", "10:30"... I also got a Button to reset the control's value property (EndTime):
<Button Grid.Column="1" Grid.Row="1" Content="Reset Time" Command="{Binding ResetTimeCommand}"/>


The full code of my ViewModel:
    class MainWindowViewModel : NotificationObject
    {
        public MainWindowViewModel()
        {

            ResetTimeCommand = new DelegateCommand<object>(this.ResetTime);

        }

        private string _txtEndTime;
        public string EndTime
        {
            get { return _txtEndTime; }
            set
            {
                _txtEndTime = value;
            }
        }

        public ICommand ResetTimeCommand { get; private set; }

        public void ResetTime(object param)
        {
            EndTime = null;
            RaisePropertyChanged(() => this.EndTime);
        }
    }

Im setting EndTime to null when the Button is pressed. This clears the input field as expected. But after clearing the field I can't type anything into it anymore. Its just not accepting any input. The EndTime Property stays null.

I have tested the same setup with a RegEx without capture groups like [0-2][0-9]:[0-5][0-9] which works with no problem. After clearing the Input I can just type another value like expected.

Maybe this has something to do with: Forum Thead 145485
Unfortunately I was not able to download the patch provided in thread 145485 (You are not authorized to download this patch). I'm using Syncfusion version 17.1.0.38.

Best regards
Tom Stein

5 Replies

JP Jagadeesan Pichaimuthu Syncfusion Team August 6, 2019 01:05 PM UTC

Hi Tom Stein, 
  
Thanks for contacting syncfusion support. 
  
Query 1 
  
Value cannot be entered in SfMaskedEdit after setting EndTime value to null 
  
We have checked your reported query and the reported behavior occurs due to mask regex expression(HH:MM format) is not supported with OR operations. Currently we are validating your reported query and we will provide more details on Aug 8th ,2019. 
  
Query 2 
  
Forum Thead 145485 – Forum thread patch could not be accessible 
  
  
Forum thread patch will not be accessible for all users. The patch could be downloaded only for the customer who created the forum thread or patch must be generated with particular customer id.  
 
Regards, 
Jagadeesan 



KP Kanniyappan Panneer Selvam Syncfusion Team August 8, 2019 05:38 PM UTC

Hi Tom Stein, 
 
Thanks for your patience. 
 
On further analysis, SfMaskedEdit does not have the direct support to achieve your requirement (Mask regex with OR operation). We suggest you to use CustomValidation which allows the value into the SfMaskedEdit. Please find the code snippet, UG links and  sample for the same. 
 
Code Snippet: 
 
XAML: 
 
<ControlTemplate x:Key="validationErrorTemplate"> 
<DockPanel> 
<TextBlock Foreground="Red" DockPanel.Dock="Top">Error</TextBlock> 
<AdornedElementPlaceholder x:Name="ErrorAdorner"/> 
</DockPanel> 
</ControlTemplate> 
 
<sf:SfMaskedEdit  x:Name="maskededit" Margin="5" 
Validation.ErrorTemplate="{StaticResource validationErrorTemplate}" 
ValidationMode="{Binding ElementName=validation ,Path=Text}" 
Mask="00:00" 
MaskType="Simple"  > 
<sf:SfMaskedEdit.Style> 
<Style TargetType="sf:SfMaskedEdit"> 
<Style.Triggers> 
<Trigger Property="ValidationMode" Value="KeyPress"> 
<Setter Property="Text"> 
<Setter.Value> 
<Binding Path="Value" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged"> 
<Binding.ValidationRules> 
<local:TimeValidator/> 
</Binding.ValidationRules> 
</Binding> 
</Setter.Value> 
</Setter> 
</Trigger> 
<Trigger Property="ValidationMode" Value="LostFocus"> 
<Setter Property="Text"> 
<Setter.Value> 
<Binding Path="Value" Mode="TwoWay" UpdateSourceTrigger="LostFocus"> 
<Binding.ValidationRules> 
<local:TimeValidator/> 
</Binding.ValidationRules> 
</Binding> 
</Setter.Value> 
</Setter> 
</Trigger> 
</Style.Triggers> 
</Style> 
</sf:SfMaskedEdit.Style> 
 
</sf:SfMaskedEdit> 
 
 
C# 
 
if (value == null) 
return new ValidationResult(false, "value cannot be empty."); 
else 
{ 
int hour = 0, minute = 0; 
 
if (value.ToString() != string.Empty &&  Int32.TryParse((value.ToString().Substring(0, 2)), out int x)) 
hour = x; 
if (value.ToString() != string.Empty && Int32.TryParse((value.ToString().Substring(3, 2)), out int y)) 
minute = y; 
 
// sets the validation result to "false" when we need to restrict the Hour inputs. 
if (hour > 23) 
return new ValidationResult(false, "Hour cannot be higher than 23."); 
 
// sets the validation result to "false" when we need to restrict the Minutes inputs. 
if (minute > 59) 
return new ValidationResult(false, "Minute  higher than 59."); 
} 
return ValidationResult.ValidResult; 
 
 
 
 
 
Please try the above solution and let us know if it is helpful. 
 
Regards,
Kanniyappan P 



TS Tom Stein August 9, 2019 11:49 AM UTC

Hi,

thank you very much for providing an alternative solution. Got everything working the way I want with the custom validation.
Are there any plans on adding support for Mask regex with OR operation to SfMaskedEdit?


Regards,
Tom Stein


SP Subburaj Pandian Veluchamy Syncfusion Team August 12, 2019 06:37 AM UTC

Hi Tom Stein, 
  
Thank you for your update. 
  
Yes, we have considered to provide this “Mask regex with OR operation in SfMaskedEdit” support and logged feature request for the same. We will implement this feature in any of our upcoming release. 
 
At the planning stage for every release cycle, we review all open features and identify features for implementation based on specific parameters including product vision, technological feasibility, and customer interest. We will let you know when this feature is implemented. We appreciate your patience until then.   
    
Regards,
Subburaj Pandian V  



JP Jagadeesan Pichaimuthu Syncfusion Team August 13, 2019 09:21 AM UTC

Hi Tom Stein, 
 
Please find the feedback portal link for the logged feature report.  
 
 
We will implement this feature in any of our upcoming release. At the planning stage for every release cycle, we review all open features and identify features for implementation based on specific parameters including product vision, technological feasibility, and customer interest. We will let you know when this feature is implemented. The provided feedback link is private and you need to login to view this feedback.  
 
We appreciate your patience until then. 
 
Regards, 
Jagadeesan 


Loader.
Live Chat Icon For mobile
Up arrow icon