How to validate textbox in c#.net? [Resolved]

Posted by Hariinakoti under C# on 4/11/2012 | Points: 10 | Views : 4763 | Status : [Member] | Replies : 23
Hi,
i want to validate text box in c#.I have two text box r there.one is pass word and another one compare password .
how to compare those textbox .plz tell me urgently.i'm waiting for ur reply...

Thanks & Regards
Hari

Thanks & Regards
Hari



Responses

Posted by: Leila on: 4/11/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
If you put the code posted by Singaravel in the Click event of the button with return statement, the message appears once after clicking the button and before doing any action.
This is a sample of the code:
void button_Click(object sender, EventArgs e)
{
if(Textbox1.Text !=Textbox2.Text)
{
MessageBox.Show("Invalid Password ");
Textbox2.Focus();
return;
}
//Do what the button should do when clickin
}

Thanks,
Leila

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 4/11/2012 [Member] Silver | Points: 50

Up
0
Down

Resolved
yes leila idea also better..

it needs to click event...

u put it next next textbox_textchanged event...

code:

void textbox1_textChanged(object sender, EventArgs e)
{
if(Textbox1.Text !=Textbox2.Text)
{
label1.text=("Invalid Password ");
Textbox2.Focus();
return;
}
//Do what the textboxaction
}


Regards,
Singaravel M

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Self-Innovator on: 4/11/2012 [Member] Bronze | Points: 25

Up
0
Down
use Comparevalidator Control of FrameWrk....

Join Hands Change lives
Thanks & Regards
Straight Edge Society

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 4/11/2012 [Member] Starter | Points: 25

Up
0
Down
is this possible in c#.net dear.already i mentioned category..

Thanks & Regards
Hari

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 4/11/2012 [Member] Silver | Points: 25

Up
0
Down
See this MSDN...

Here is there code for compare passwords with screenshots...

http://msdn.microsoft.com/en-us/library/aa479013.aspx#aspnet-validateaspnetservercontrols_topic4

Regards,
Singaravel M

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 4/11/2012 [Member] Starter | Points: 25

Up
0
Down
Plz check my category then u can answer to me.iam using windows forms yar....


Thanks & Regards
Hari

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 4/11/2012 [Member] Starter | Points: 25

Up
0
Down
Hello Plz quick respond my question

Thanks & Regards
Hari

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 4/11/2012 [Member] Silver | Points: 25

Up
0
Down
if(Textbox1.Text !=Textbox2.Text)

{
MessageBox.Show("Invalid Password ");
Textbox2.Focus();
}


Regards,
Singaravel M

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 4/11/2012 [Member] Silver | Points: 25

Up
0
Down
in my knowledge, I know windows forms like these only...

anybody knews different, plz post...

Regards,
Singaravel M

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 4/11/2012 [Member] Starter | Points: 25

Up
0
Down
Thank you sakthi...


Thanks & Regards
Hari

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 4/11/2012 [Member] Starter | Points: 25

Up
0
Down
Hi singaravel ur code is working.If we give wrong text alert message coming.but we enter every letter that error message coming always upto fill the all letters and we enter each letter we'll click that error message

Thanks & Regards
Hari

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 4/11/2012 [Member] Silver | Points: 25

Up
0
Down
okay

Regards,
Singaravel M

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 4/11/2012 [Member] Silver | Points: 25

Up
0
Down
yes...

that code alerts upto, when u r entering correct password...

Regards,
Singaravel M

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 4/11/2012 [Member] Starter | Points: 25

Up
0
Down
but it is very disturbing for customers na...

Thanks & Regards
Hari

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 4/11/2012 [Member] Silver | Points: 25

Up
0
Down
just a min..

Regards,
Singaravel M

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 4/11/2012 [Member] Starter | Points: 25

Up
0
Down
ok

Thanks & Regards
Hari

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 4/11/2012 [Member] Silver | Points: 25

Up
0
Down
write that code in next textbox_textchanged event...

Regards,
Singaravel M

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 4/11/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi

Please See this

http://www.eggheadcafe.com/community/csharp/2/10035738/textbox-validation.aspx

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 4/11/2012 [Member] Starter | Points: 25

Up
0
Down
thanq leela and singaravel

Thanks & Regards
Hari

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 4/11/2012 [Member] Silver | Points: 25

Up
0
Down
welcome hari

Regards,
Singaravel M

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 4/11/2012 [Member] Bronze | Points: 25

Up
0
Down

Hariinakoti

YOu May Get Clear idea..

Check it
http://www.codeproject.com/Articles/2608/C-Validating-TextBox-Control

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Leila on: 4/11/2012 [Member] Starter | Points: 25

Up
0
Down
You are welcome, Hariinakoti

Thanks,
Leila

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 9/17/2012 [Member] Bronze | Points: 25

Up
0
Down
Please try this,
<asp:CompareValidator runat=server ControlToValidate=txtRePWord ControlToCompare=txtPWord ErrorMessage="Passwords do not match." />

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response