Add IBAN validation
This commit is contained in:
@ -155,6 +155,7 @@
|
||||
|
||||
<Label Content="IBAN:" HorizontalAlignment="Left" Margin="10,12,0,0" VerticalAlignment="Top" Padding="2"/>
|
||||
<TextBox x:Name="IbanInput" IsReadOnly="True"
|
||||
TextChanged="IbanInput_TextChanged" LostFocus="IbanInput_LostFocus"
|
||||
Margin="0,10,10,0" VerticalAlignment="Top" FontSize="14" Padding="2" Grid.Column="1" Height="25"/>
|
||||
|
||||
<Label Content="BIC:" HorizontalAlignment="Left" Margin="10,42,0,0" VerticalAlignment="Top" Padding="2"/>
|
||||
|
@ -385,8 +385,8 @@ namespace WGneu.Windows {
|
||||
return true; // TODO
|
||||
}
|
||||
|
||||
private void InputTextChanged(TextBox input, Func<TextBox, ValidationResult> checker) {
|
||||
var res = checker(input);
|
||||
private void InputTextChanged(TextBox input, bool optional, Func<TextBox, bool, ValidationResult> checker) {
|
||||
var res = checker(input, optional);
|
||||
Valid[input] = res.IsValid;
|
||||
if (res.IsValid)
|
||||
Validator.SetInputValid(input);
|
||||
@ -395,8 +395,8 @@ namespace WGneu.Windows {
|
||||
UpdateButtons();
|
||||
}
|
||||
|
||||
private void InputLostFocus(TextBox input, Func<TextBox, ValidationResult> checker, string? msg) {
|
||||
var res = checker(input);
|
||||
private void InputLostFocus(TextBox input, bool optional, Func<TextBox, bool, ValidationResult> checker, string? msg) {
|
||||
var res = checker(input, optional);
|
||||
if (!res.IsValid)
|
||||
MessageBox.Show(res.ErrorContent.ToString(), msg ?? res.ErrorContent.ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
}
|
||||
@ -406,27 +406,35 @@ namespace WGneu.Windows {
|
||||
}
|
||||
|
||||
private void PhoneNrInput_TextChanged(object sender, RoutedEventArgs e) {
|
||||
InputTextChanged((TextBox)sender, Validator.CheckPhoneNumber);
|
||||
InputTextChanged((TextBox)sender, true, Validator.CheckPhoneNumber);
|
||||
}
|
||||
|
||||
private void PhoneNrInput_LostFocus(object sender, RoutedEventArgs e) {
|
||||
InputLostFocus((TextBox)sender, Validator.CheckPhoneNumber, null);
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckPhoneNumber, null);
|
||||
}
|
||||
|
||||
private void EmailInput_TextChanged(object sender, RoutedEventArgs e) {
|
||||
InputTextChanged((TextBox)sender, Validator.CheckEmailAddress);
|
||||
InputTextChanged((TextBox)sender, true, Validator.CheckEmailAddress);
|
||||
}
|
||||
|
||||
private void EmailInput_LostFocus(object sender, RoutedEventArgs e) {
|
||||
InputLostFocus((TextBox)sender, Validator.CheckEmailAddress, null);
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckEmailAddress, null);
|
||||
}
|
||||
|
||||
private void IbanInput_TextChanged(object sender, RoutedEventArgs e) {
|
||||
InputTextChanged((TextBox)sender, true, Validator.CheckIban);
|
||||
}
|
||||
|
||||
private void IbanInput_LostFocus(object sender, RoutedEventArgs e) {
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckIban, null);
|
||||
}
|
||||
|
||||
private void LfbisNrInput_TextChanged(object sender, RoutedEventArgs e) {
|
||||
InputTextChanged((TextBox)sender, Validator.CheckLfbisNr);
|
||||
InputTextChanged((TextBox)sender, true, Validator.CheckLfbisNr);
|
||||
}
|
||||
|
||||
private void LfbisNrInput_LostFocus(object sender, RoutedEventArgs e) {
|
||||
InputLostFocus((TextBox)sender, Validator.CheckLfbisNr, "Betriebsnummer ungültig");
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckLfbisNr, "Betriebsnummer ungültig");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user