Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2010
    Posts
    23
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Exclamation Phone Number Display

    Just wondering what the code is for a phone number to be displayed
    nn-nnnnnnnn

    for example: 67 43289482

    current code is
    Code:
    var pn = document.contact_form.phonenum.value;
    if ((pn.length != 10) || (/[^0-9]/g.test(pn))) {  // 10-digit phone number
    alert ( "Please fill in your 10-digit telephone number" );
    return false;
    }

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,518
    Thanks
    3
    Thanked 506 Times in 493 Posts
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #3
    New Coder
    Join Date
    Jun 2010
    Posts
    23
    Thanks
    7
    Thanked 0 Times in 0 Posts
    fixed it just
    Code:
    {
       if(document.contact_form.phonenum.value.search(/\d{2} \d{8}/)==-1)
       {
          alert("The phone number you entered is not valid.\r\nPlease enter a phone number with the format xx xxxxxxx");
          return false;
       }
    }
    Last edited by bubble00000; 06-22-2010 at 03:13 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •