Need a validation code for a textbox in windows form, that allow me to enter the values like
1
11
1.3
1.33
11.33
I am using this text box for entering tax values .
this textbox should allow only two digits before and after decimal point .
Thanks in advance :)
waqas memonPosted Jul 20, 2013, 12:04 PM
Ramesh UshodayaPosted Jul 24, 2013, 2:49 AM
Thank you so much :)
Iftikar HussainPosted Jul 20, 2013, 4:24 AM
set the mask as 00.00
Regards,
Iftikar
Ramesh UshodayaPosted Jul 20, 2013, 3:13 AM
I need this validation when Keypress.
It should work like this
User can allow to enter upto two digits before and after the decimal point.
if user enter two digits it should not allow for the third digit but it can allow ".".
if user enter "." it should allow only two digits after ".".
like 2, 22, 2.3, 2.33, .3, .33, 2.33, 22.33
A Big Thanks for the replies :) .
But need a Perfect solution :( .
Iftikar HussainPosted Jul 19, 2013, 10:32 AM
this.textBox1.KeyPress += new KeyPressEventHandler(this.textBox1_KeyPress);
Regards,
Iftikar
Ramesh UshodayaPosted Jul 19, 2013, 10:24 AM
I need this validation when key press .
Is it possible ?
Iftikar HussainPosted Jul 19, 2013, 10:20 AM
Try like this
you need to do this after entering the data in textbox
this.textBox2.Leave += new System.EventHandler(this.textBox1_TextLeave);
Regards,
Iftikar
Pankaj PandeyPosted Jul 19, 2013, 9:47 AM
create a function in which split the textbox data by ".".
var x=txtbox.text.Split(".");
string y=x[0].tostring();
string z=x[1].tostring();
now check that if x.lenght>2 or y.length>2 then raise validation.