C# Tutorials and offshore development in India
Tutorials Resources Forum Reviews Communities Interview Jobs Projects Training Videos


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...


Birthday Greetings
Learn Windows 7: How to move the file from one folder to the other folder in Epic Browser   In this resource I will explain how to move the file from one folder to the other folder in Epic Browser.



Forums » .NET » .NET »

how can validate the phone number entered in textbox


Posted Date: 14 Nov 2006      Posted By:: Mohammed Abdul Shameem    Member Level: Silver    Member Rank: 0     Points: 2   Responses: 5



i want to validate telephone number
bcaz if i enter zeros, it will accept
so plz help me how we can validate the phone number





Responses

Author: VeeraReddy Palnati     Member Level: Silver      Member Rank: 0     Date: 14/Nov/2006   Rating: 2 out of 52 out of 5     Points: 2

Hi

By using regular expression control of the ASP.NET we can validate the Telephone numbers
Bye
Regards
Veera



Author: Pankaj Mishra     Member Level: Diamond      Member Rank: 0     Date: 14/Nov/2006   Rating: 2 out of 52 out of 5     Points: 2

Hi
yes you can use regular expression validator

Regards,
Pankaj
MyBlog



Author: Mohan Kumar     Member Level: Diamond      Member Rank: 29     Date: 14/Nov/2006   Rating: 2 out of 52 out of 5     Points: 2

hi ,

use regular expression validation control.

for eg,

here crv -> regular experssion validation control

crv.ControlToValidate = "textbox1"
crv.ValidationExpression = "([0-9])*"
crv.Text = "enter numeric value"

hope this will help you.



Author: Vamshi Chilukuri     Member Level: Silver      Member Rank: 0     Date: 14/Nov/2006   Rating: 2 out of 52 out of 5     Points: 2

Hi, this is using javascript........u can validate the phone no. using regular expression validator also----


if((Phone).length == 0)
{

error_message+="Enter phone"+"\n";
error=true;
}
var regEx = /^[0-9]{3}([\-][0-9]{4})?/;
var indexHome=Phone.indexOf('-');

if(Phone.length>0)
{
if(indexHome < 0)
{
if(isNaN(Phone))
{
error_message+=" phone should be numeric"+"\n";
error=true;
}
else if(kPhone.length != "7" )
{
error_message+="phone should be in 7 digits"+"\n";
error=true;
}
}

else if(indexHome !="3")
{
error_message +=" phone should be in 1231111 or 123-1111 format"+ "\n";
error=true;
}
else
{
if( (isNaN( Phone.substring(0,3) ))||(isNaN(Phone.substring(4,9)) ) )
{
error_message +=" phone should be in 1231111 or 123-1111 format"+ "\n";
error=true;
}
if(isNaN(Phone.substring(4,9).length!="4"))
{
error_message +=" phone should be in 1231111 or 123-1111 format"+ "\n";
error=true;
}
}
}



Author: Subodh kumar Prajapati     Member Level: Gold      Member Rank: 146     Date: 22/Jun/2007   Rating: 2 out of 52 out of 5     Points: 2

Hello friend,
you can use the regular expression control in asp.net. It is very easy to use. you can use this control at static and dynamicly.

Ok byee
From : Subodh kumar
9891428085



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : how to give database connections in app.config and how can we call that connection in the form?
Previous : what exactly IsPostBack do?
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



About Us    Contact Us    Privacy Policy    Terms Of Use