Can php add a comma to input field on a form???

Discussion in 'PHP' started by yoyo99, Apr 13, 2009.

  1. #1
    I want to add a comma after 4 characters are typed in by a user in an input field (which will be numbers). For example: user types in 1234 and I would like it to display 1,234 as soon as they type in the fourth character, which is 4 in the example. Any ideas would be appreciated... thanx! :)
     
    yoyo99, Apr 13, 2009 IP
  2. wesd

    wesd Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You would need to do this in Javascript, not PHP. Here's a thread I found that should do it: http://www.codingforums.com/showpost.php?p=214377&postcount=3
     
    wesd, Apr 13, 2009 IP
  3. zendowind

    zendowind Banned

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    It can be done only ( if we need to choose from the most common options ) via JavaScript ( which is client side language ).
     
    zendowind, Apr 13, 2009 IP
  4. diligenthost

    diligenthost Peon

    Messages:
    685
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
  5. tariq1654

    tariq1654 Active Member

    Messages:
    291
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    73
    #5
    Using string functions you can do it. But its much better if u try javascript.
     
    tariq1654, Apr 14, 2009 IP
  6. zendowind

    zendowind Banned

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Maybe you could tell us - which function can change input fields value/format ? :eek:
     
    zendowind, Apr 14, 2009 IP
  7. yoyo99

    yoyo99 Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thank you all for your replies. I wasn't sure if PHP could do it. Now I am gonna look at the javascript links you guys posted. Thanks so much!
     
    yoyo99, Apr 14, 2009 IP