none
HOw to use TextBox validation using regex and decimal format RRS feed

  • Question

  • Dear all,

    I am stuck on a small issue.

    I need to add a validation entry on WPF text box. The rules is that the Text box should accept only numeric value and in case of a decimal value, the format of the decimal value should check the proper decimal separator from system settings.

    What is the way to add this Textbox validation and used of regex if needed ?

    Thanks for sample if any

    regards

    Monday, May 7, 2018 6:39 AM

All replies

  • Hi wakefun,

    >>” What is the way to add this Textbox validation and used of regex if needed ?”

    You could use the regex to do it like Bob_Bao’s reply on this case: WPF textbox to accept decimal numbers

    >>” the format of the decimal value should check the proper decimal separator from system settings.”

    When you format the decimal value, the result string would be affected by the formatting information of the current NumberFormatInfo object. You did not need to check it manually. Please read The Fixed-Point ("F") Format Specifie for more details.

    Best Regards,

    Xavier Xie


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, May 8, 2018 6:04 AM
    Moderator