Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8322975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:34:01+00:00 2026-06-08T23:34:01+00:00

We have an order form which takes credit cards from mobile browsers: <input type=number

  • 0

We have an order form which takes credit cards from mobile browsers: <input type=”number” id=”txtCCNumber” />

Also in addition to that we have a JavaScript which removes any non-integer characters that are inserted into the field:

$('input#txtCCNumber').keyup(function(e)
{
    var ccnum = $(this).val();
    $(this).val(ccnum.replace(/[^\d]/g, ''));
});

However we just realized that it appears that when people using an iPhone try to put their credit card in, iPhone automatically adds a comma every 3 numbers (because of the JavaScript).

Does anybody know a way to fix this JavaScript so it works?

I do not want to use type=”tel”. That is not a solution in this case.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T23:34:04+00:00Added an answer on June 8, 2026 at 11:34 pm

    Personally, I don’t think credit card numbers are an appropriate use of input type="number". According to the spec:

    The input element with a type attribute whose value is “number” represents a precise control for setting the element’s value to a string representing a number.

    Credit card “numbers” are strings of digits, but they don’t identify a particular numeric value, and it wouldn’t make sense for a user to enter a credit card number using the up and down arrows that some browsers attach to the input field. Your best bet is simply to use input type="text".

    Also, attaching that JavaScript to the keyup event is going to annoy people like me who want to enter their credit card number with separators because it’s easier to spot check. Just let people enter their card number however they like and normalize it later.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form on my company's site which takes a name, telephone number,
I have a registration form and used fieldset to order the input fields in
I have a form which is supposed to be redirected to order success page
I have a little php/mysql app I put together that takes an input form
I have this code in my HTML form: <form action=cart.php method=post> <input type=hidden value=1
I have an order form where a user gives some input about a product
I have a form-validation function which validates and also checks to see if the
I have an order form with about 30 text fields that contain numerical values.
I have a multi-step order form built in this manner: Step 1: Choose category
I have inherited a project, that provides an order form to a customer. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.