Quick Search
Sunbelthost Hosting - Colocation and Dedicated Servers

Threads: 21,763
Posts: 83,205
Members: 24,315
Newest member: joemccue

Web Hosting


 
  #1  
Old 05 Oct 2009, 08:45 PM
webpanda's Avatar
webpanda webpanda is offline
Established Member
 
Join Date: Aug 2009
Posts: 45
javascript regular expression for phone, please help me check for 411

hi can anyone help me with this probelm?

isNumeric?

eh

ok, the problem is i need to use regular expression (javascript) to check for a phone number, but the phone number can't be a joke number like 411, 911, 555, 311

my problem is when i have to somehow search the first three numbers and not let them equal this sequence, but no where i see on the web do i find any thing that helps me with this.. should i just use plain javascript to test it after it passes the test?

or is there something like

/^\d{3}[^(411)]-\d{4}$/
???
Reply With Quote
  #2  
Old 05 Oct 2009, 09:29 PM
Alan's Avatar
Alan Alan is offline
Moderator
 
Join Date: Feb 2007
Location: Ireland
Posts: 843
Well first off, I'm not is_numeric... but if we can get past that then lets move on.

So you dont want numbers like 411, 765 etc... I just want to get an idea of what you mean by a "joke" number?
So here's a few thoughts for your head:
  • Is 911/999/112 etc... a joke number (emergency numbers)?
  • What about premium numbers and network related numbers? (e.g. I'm with the Meteor network in Ireland and my customer care number is 1905)
  • What is a joke number (please be specific), hard to test for a pattern without knowing the pattern.

May I suggest applying a pattern check that will test the length of the number and the preceding digits (area codes). That should work nicely. :-)
__________________
“The best thing about a boolean is even if you are wrong, you are only off by a bit.”
Reply With Quote
  #3  
Old 06 Oct 2009, 01:32 AM
is_numeric's Avatar
is_numeric is_numeric is offline
Moderator
 
Join Date: Apr 2009
Location: The toon
Posts: 1,088
Quote:
Well first off, I'm not is_numeric... but if we can get past that then lets move on.
It must be hard to get past that.... Its ok, You're only human!
Reply With Quote
  #4  
Old 06 Oct 2009, 04:46 AM
Alan's Avatar
Alan Alan is offline
Moderator
 
Join Date: Feb 2007
Location: Ireland
Posts: 843
Quote:
Originally Posted by is_numeric View Post
It must be hard to get past that.... Its ok, You're only human!


PHP Code:
function transform_into_is_numeric($alan,$is_numeric) {
    if(
$alan !== $is_numeric) {
        
$alan = clone $is_numeric;
    }
    
    return 
$alan;

__________________
“The best thing about a boolean is even if you are wrong, you are only off by a bit.”
Reply With Quote
  #5  
Old 06 Oct 2009, 06:23 PM
webpanda's Avatar
webpanda webpanda is offline
Established Member
 
Join Date: Aug 2009
Posts: 45
Quote:
Originally Posted by Alan View Post


PHP Code:
function transform_into_is_numeric($alan,$is_numeric) {
    if(
$alan !== $is_numeric) {
        
$alan = clone $is_numeric;
    }
    
    return 
$alan;

php!

yea! ok for this exercise my prollum is that i can' thave any such number where it's like

\d11

no preceding 3 digits to be ?11 it's only for school, but how do we do this?
Reply With Quote
  #6  
Old 07 Oct 2009, 09:12 PM
webpanda's Avatar
webpanda webpanda is offline
Established Member
 
Join Date: Aug 2009
Posts: 45
ok got it

ok so we had to use look ahead

/^(?!555|\d11)\d{3}-\d{4}$/

ya i figured it out for the class!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Background Check Search Allenhan General Questions 0 29 Jun 2007 12:39 AM
regular expression sm9ai Client & Server Side Scripting (PHP, ASP, JavaScript) 1 13 Apr 2006 01:35 AM
Check out my JavaScript... trefrog Website Design Reviews 10 22 Jan 2006 03:47 AM


All times are GMT -5. The time now is 01:23 PM.


 

Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Forums Copyright © 2004-2010, WebDevForums.com. Web design by Miami Web Design. All Rights Reserved.