plz help me in validation plzzzzzzzzzzz [Resolved]

Posted by Subhadip under C# on 12/16/2010 | Points: 10 | Views : 1506 | Status : [Member] | Replies : 3
hi
i want some of the following validation code can any one help me plz for(C# WINDOW APPLICATION)

1 VALIDATION FOR RADIO BUTTON IN NOT CHECKED
2 VALIDATION FOR CHECK BOX IN NOT CHECKED
3 VALIDATION FOR DROP DOWN BOX IF NOT SELECTED
4 VALIDATION FOR PHONE NO (should not exit 10 for mobile and 8 for land phone & must be integer)

plz help in code




Responses

Posted by: Roopkt on: 12/16/2010 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi Subhadip,

Read my Answers below.


Q1 VALIDATION FOR RADIO BUTTON IN NOT CHECKED ?

if (!radioButton1.Checked)
{
MessageBox.Show("Please select one option!")
}

Q2 VALIDATION FOR RADIO BUTTON IN NOT CHECKED ?

if (!checkBox1.Checked)
{
MessageBox.Show("Please select one option!")
}

Q3 VALIDATION FOR DROP DOWN BOX IF NOT SELECTED
You can make the index of the default option is 0 and write the below code.

if(comboBox1.SelectedIndex == 0)
{
MessageBox.Show("Please select one option!")
}

Q4 VALIDATION FOR PHONE NO (should not exit 10 for mobile and 8 for land phone & must be integer)

String val = textBox1.Text.ToString();
Regex reg = new Regex(@"(^\d{8}$)|(^\d{10}$)", RegexOptions.None);
if(!reg.IsMatch(val))
{
MessageBox.Show("Please enter a valid phone / Mobile number");
}


Hope my answers were helpful.



Regards,
Rupesh Kumar Tiwari

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

Posted by: Vuyiswamb on: 12/17/2010 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
Good Day Subhadip

I dont like your Subject. Please dont scream if you need help.


Thank you for posting at Dotnetfunda
[Administrator]

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

Posted by: Naimishforu on: 6/22/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Cool Answer Dude!! Nice

Thanks,
Naimish
http://dotnetinterview.zxq.net/
http://naimishpandya.blogspot.in/

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

Login to post response