I have the following:
<StackPanel Grid.Row="3" Orientation="Horizontal"> <Label Width="80" Content="Phone:"/> <ig:XamMaskedInput Width="100" Text="{Binding PhoneNumber}" Mask="(###) ###-####" InvalidValueBehavior="DisplayErrorMessage"/> </StackPanel>
I would like to know how to set the error message to display.
Thanks.
i used this for IP validation
xaml:
<ige:XamMaskedInput Text="{Binding Value,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" x:Name="maskedEditor" InvalidValueBehavior="DisplayErrorMessageAndRevertValue" ValidationError="MaskedEditor_OnValidationError" Mask="{}{number:1-223}.{number:0-255}.{number:0-255}.{number:0-255}"/>
CodeBehind:
private void MaskedEditor_OnValidationError(object sender, EditModeValidationErrorEventArgs e)
{
e.ErrorMessage = "0 is not a valid entry, please specify a value between 1 and 223";
}
Hello,
I am just checking if you require any further assistance on the matter.
Hi,
Thank you for your reply. I have been looking into your scenario and I can suggest you put a hidden Textblock near to the XamMaskedInput and makes it visible when the input is focused by handling the GotFocus and LostFocus events like e.g. :
<Editors:XamMaskedInput x:Name="maskedEditor" Mask="(###) ###-####" Grid.Column="0" Height="25" Width="100" Text="{Binding PhoneNumber}" GotFocus="maskedEditor_GotFocus_1" LostFocus="maskedEditor_LostFocus_1" >
<Editors:XamMaskedInput.ValueConstraint>
<Editors:ValueConstraint MaxLength="10" />
</Editors:XamMaskedInput.ValueConstraint>
</Editors:XamMaskedInput>
<TextBlock Visibility="Collapsed" Width="100" Height="25" Foreground="Red"x:Name="txtBlock" Grid.Column="1">Please use only digits</TextBlock>
private void maskedEditor_GotFocus_1(object sender, RoutedEventArgs e)
this.txtBlock.Visibility = Windows.UI.Xaml.Visibility.Visible;
private void maskedEditor_LostFocus_1(object sender, RoutedEventArgs e)
this.txtBlock.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
Please let me know, if you need any further assistance on this matter
Hi Yanko,
Thank you for your response.
I am not trying to validate the masked input, what I am trying to do is to inform the user what he/she should put in.
For example, if the mask for a textbox is #####, it only accepts numbers, when the user keys in letters, the textbox will not accept the user's input, but I would like to inform the user that this textbox only accept numbers. I was thinking to display the error message to let the user know.