Am doing Hospital details.For that,Am puuting 13 textboxes and 2 buttons.It named as
Name,Address1,Address2,City,State,PinCode,WebSite,FirstName,LasName,Middle Name,E-mail Id,Phoneno,Fax as textboxes and save n Cancel as buttons.
In name,if we enter any number other than alphabets it should display error.For every thg,it should display like this.For Website or E-mail,if @ or . (dot) is not there it should display error. For all it should display like that.
Plz send this as fast as possible.
Loading
Anand ThakurPosted Feb 10, 2006, 5:22 AM
e.g. for email you can use ^[\w-]+@[\w-]+\.(com|net|org|edu|mil)$
Santhi GPosted Feb 8, 2006, 11:55 PM
And in Pincode,phone number we should enter only numbers.other than numbers ,it should display error.
For Website and for E-mailID,it should contain @ at the right side only n only onedot(.), after dot we have either com or org.
Am doing this in .net using Project type as VisualC# in asp.net web application.
Now am learning C#,but I want the code in c# with all controls should be applied including validations. Plz send as soon as possible.Its urgent.
SimonPosted Feb 8, 2006, 9:03 PM
char[] numbers = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0'};
if (textBox1.Text.IndexOfAny(numbers) != -1)
MessageBox.Show("found numbers");
else
MessageBox.Show("didn't found number");
and for the email, you can do such validation as
if (textBox1.Text.IndexOf('@') != -1 && textBox1.Text.IndexOf('.') != -1 && textBox1.Text.IndexOf('@') < textBox1.Text.IndexOf('.'))
You will need to add some validation to make sure that "@." doesn't validate successfully...have a deeper look at the IndexOf method and other string manipulation methods.
Simon