Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Senior Member jf1288's Avatar
    Join Date
    Sep 2003
    Posts
    215
    Member #
    3300
    I'm looking for a script that will take a form input and maintain a format such as:

    (___) ___-____

    It should only allow numeric input and make the correct placement of characters, so as they fill it out it becomes:

    (55_) ___-____

    (555) 5__-____

    (555) 555-____

    (555) 555-5555

    And then cap it at 10 numbers.

    I found one script that was for sale that does this and many other field formats, but I'm focused on just making it as small as possible and doing just this. Is there anything like this already available, or can someone throw me a handmade script?

    Thanks,
    Jordan
    If its not in Family Guy its not worth it.

  2.  

  3. #2
    Senior Member imagn's Avatar
    Join Date
    Jul 2007
    Location
    Los Angeles
    Posts
    156
    Member #
    15594
    I THINK this is what you're looking for... it's an auto-tab function but field validation (i.e. numbers only) isn't included in this script, but could easily be added.

    Javascript
    =========================================

    /* --------------------------------------------------- */
    /* AUTO TAB */
    /* --------------------------------------------------- */
    var isNN = (navigator.appName.indexOf("Netscape")!=-1);
    function autoTab(input,len, e) {
    var keyCode = (isNN) ? e.which : e.keyCode;
    var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
    if(input.value.length >= len && !containsElement(filter,keyCode)) {
    input.value = input.value.slice(0, len);
    input.form[(getIndex(input)+1) % input.form.length].focus();
    }
    function containsElement(arr, ele) {
    var found = false, index = 0;
    while(!found && index < arr.length)
    if(arr[index] == ele)
    found = true;
    else
    index++;
    return found;
    }
    function getIndex(input) {
    var index = -1, i = 0, found = false;
    while (i < input.form.length && index == -1)
    if (input.form[i] == input)index = i;
    else i++;
    return index;
    }
    return true;
    }


    =================================

    HTML Event
    =================================

    onkeyup="return autoTab(this, 3, event);"

    The value "3" is how many characters before it jumps to the next field.

    ==================================

  4. #3
    Senior Member jf1288's Avatar
    Join Date
    Sep 2003
    Posts
    215
    Member #
    3300
    More like the phone number mask from Wiseblocks.

    http://www.wiseblocks.com/input-comp...CTextMask.html

    I just want the phone number mask, though. I want to avoid a giant library.
    If its not in Family Guy its not worth it.

  5. #4
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    I wrote one of these once upon a time... I think Iost it, though, in various HD switches. I'll look into it and see if I can dig it up. It wasn't a long one -- it was something like 100 LOC or so.


Remove Ads

Posting Permissions

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

Search tags for this page

html input phone number mask

,
html mask phone number
,
html phone number input mask
,
input mask for phone number html-code
Click on a term to search for related topics.
All times are GMT -6. The time now is 05:09 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com