Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jul 11, 2012 09:51 AM by Mudasir.Khan
Member
246 Points
99 Posts
Jul 11, 2012 09:28 AM|LINK
Hi Frnds. . .
Please help me with the validation expression for Mobile No And Telephone No.
Thanks in Advance. . .
Participant
1044 Points
424 Posts
Jul 11, 2012 09:42 AM|LINK
Hi,
write this code in click event
function Validate() { var x = document.getElementById("txtPhomenumber").value; if(isNaN(x)|| x.indexOf(" ")!=-1) { alert("Enter numeric value"); return false; } if (x.length > 10 || x.length > 8 ) { alert("enter 10 or 8 characters"); return false; } if (x.charAt(0)!="9" || x.charAt(0)!="2") { alert("it should start with 9 or 2 "); return false; } }
960 Points
458 Posts
for mobile --> ^[7-9][0-9]{9}$ for teliphone (landline)n--> /^[0-9]\d{2,4}-\d{6,8}$/
Star
8976 Points
1659 Posts
Jul 11, 2012 09:43 AM|LINK
all countries have Different types of writing method of Telephone Numbers and Mobile Numbers
Like UnitedStates : 408-555-1212
In Pakistan : 0333-3333333 OR 0213-3333333
So, I think you should Defind which format you want? or you can Allow only Numeric character.. not ABCDEF,
you can Allow Numeric character with lenght of Phone Number Like 11 or 10 etc.
Also try these links
Good luck`
Jul 11, 2012 09:46 AM|LINK
Hi you can do like this also
<script language=Javascript type="text/javascript"> function isNumberKey(evt) { var charCode = (evt.which) ? evt.which : event.keyCode if (charCode > 31 && charCode != 45 && charCode != 40 && charCode != 41 && (charCode < 48 || charCode > 57)) return false;
return true;
} </script>
<asp:TextBox ID="txtPhone" onkeypress="return isNumberKey(event)" runat="server"></asp:TextBox>
go through this link
http://blog.stevenlevithan.com/archives/validate-phone-number
All-Star
15346 Points
3142 Posts
Jul 11, 2012 09:51 AM|LINK
are you asking for regulare expression ?
then it depends on the country for which country do you need it you may also get it easily on google if you mention "regular expression COUNTRY mobile" ?
shl_csit
Member
246 Points
99 Posts
Validation Expression
Jul 11, 2012 09:28 AM|LINK
Hi Frnds. . .
Please help me with the validation expression for Mobile No And Telephone No.
Thanks in Advance. . .
nageshrgosul
Participant
1044 Points
424 Posts
Re: Validation Expression
Jul 11, 2012 09:42 AM|LINK
Hi,
write this code in click event
narasappa
Participant
960 Points
458 Posts
Re: Validation Expression
Jul 11, 2012 09:42 AM|LINK
for mobile --> ^[7-9][0-9]{9}$ for teliphone (landline)n--> /^[0-9]\d{2,4}-\d{6,8}$/ravi.jadiyannavar@gmail.com
Pls Mark This Post As Answer If it Helps U..
Thanku
MahadTECH
Star
8976 Points
1659 Posts
Re: Validation Expression
Jul 11, 2012 09:43 AM|LINK
all countries have Different types of writing method of Telephone Numbers and Mobile Numbers
Like UnitedStates : 408-555-1212
In Pakistan : 0333-3333333 OR 0213-3333333
So, I think you should Defind which format you want? or you can Allow only Numeric character.. not ABCDEF,
you can Allow Numeric character with lenght of Phone Number Like 11 or 10 etc.
Also try these links
Good luck`
Mahad Bin Mukhtar
Remember to Mark the replies as Answers
The easiest day was 'yesterday'.
MCP, MCSD
For .NET TECH Blog
nageshrgosul
Participant
1044 Points
424 Posts
Re: Validation Expression
Jul 11, 2012 09:46 AM|LINK
Hi you can do like this also
<div class="comment-right-col">use this javascript <div><script language=Javascript type="text/javascript">
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && charCode != 45 && charCode != 40 && charCode != 41 && (charCode < 48 || charCode > 57))
return false;
return true;
}
</script>
<asp:TextBox ID="txtPhone" onkeypress="return isNumberKey(event)" runat="server"></asp:TextBox>
go through this link
http://blog.stevenlevithan.com/archives/validate-phone-number
</div> </div>Mudasir.Khan
All-Star
15346 Points
3142 Posts
Re: Validation Expression
Jul 11, 2012 09:51 AM|LINK
are you asking for regulare expression ?
then it depends on the country for which country do you need it you may also get it easily on google if you mention "regular expression COUNTRY mobile" ?