Ankush

Ankush

  • NA
  • 267
  • 63.2k

Allow 2 decimal points / dots in textbox using c#

Mar 15 2016 1:24 AM
I am developing a windows application using c#. 
The user enters a website name which should allow only 2 dots for eg  www.google.com
I have written but that is accepting only 1 dot. The code I have written is :-
  1. if ((e.KeyChar == '.') && ((sender as TextBox).Text.IndexOf('.') > -1))  
  2. {  
  3.        e.Handled = true;  
  4. }  
Thanks in Advance ...!!!

Answers (4)