Posts

Showing posts from September, 2025

pasting

using System.Linq; using System.Text.RegularExpressions; using System.Windows; using System.Windows.Controls; using System.Windows.Input; namespace OnlyCapsNumbers {     public partial class MainWindow : Window     {         // ✅ Allowed chars: A–Z and digits         private static readonly Regex AllowedRegex = new Regex("^[A-Z0-9]$");         public MainWindow()         {             InitializeComponent();         }         // Block invalid typing         private void txtInput_PreviewTextInput(object sender, TextCompositionEventArgs e)         {             e.Handled = !AllowedRegex.IsMatch(e.Text);         }         // Sanitize pasted text (check each character)         private void txtInpu...