C# WPF Text Box as International Phone Number Validation

I have a textbox in c# wpf (windows presentation foundation) and I want to save the textbox data as international phone number e.g (+91-333-5548771). If someone type against this format he will receive error message (ideally on real time). Can anyone help me? I am completely new and trying adding code under

private void textBox_TextChanged(object sender, TextChangedEventArgs e)


1 answer

  • answered 2017-11-14 23:26 Mr.AF

    i tried before to fix this question to how to check input validation so i did these steps and i recommend you to do that if you want to check input validation .

    if(check string length to be a fixed length depend on international phone numbers)
    if(make a country first two number +98 list and check is there any country for this phone number)
    if(check all the characters to be numerical )

    then all done

    the phone is correct

    you can check it synchronized and asynchronized and i recommend you to do synchronized because it will get all of CPU power to calculate input in constant .