Hi,
i need to block input if first char 2 and second char must not be more 5. And first char input must be 1 or 2. Specifically I need the input of only 1-25 and nothing else. I tried and only allow entry of numbers, but fail to limit specified :(.
Dum_ 0 Newbie Poster
Recommended Answers
Jump to PostOne way would be to limit the keys the user can press:
private void TextBox_KeyPress(object sender, KeyPressEventArgs e) { //only allow numbers and control keys if (!char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar)) { e.Handled = true; } else if (char.IsControl(e.KeyChar)) { e.Handled = false; } else { //using this rather …
All 4 Replies
ddanbe 2,724 Professional Procrastinator Featured Poster
Geekitygeek 480 Nearly a Posting Virtuoso
Dum_ 0 Newbie Poster
Geekitygeek 480 Nearly a Posting Virtuoso
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.