Skip to content
An input element that only allows credit card numbers
JavaScript HTML
Branch: master
Clone or download
Latest commit dd83fd1 Sep 14, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Create CODEOWNERS Jan 24, 2018
demo oops didn't push fixes Jul 16, 2018
images add card icons for valid card types May 26, 2015
test run format Jul 16, 2018
.gitignore Tedium automated v3 element updates. Aug 16, 2018
.npmignore Tedium automated v3 element updates. Aug 16, 2018
.travis.yml Only generate types once on Travis Sep 7, 2018
CONTRIBUTING.md [skip ci] Update contribution guide May 17, 2016
README.md update readme Jul 16, 2018
bower.json Add `bower.json` so that webcomponents.org can read the repo. Sep 14, 2018
cc-validator.js clean up elements Jul 16, 2018
formatconfig.json
gold-cc-input.js Remove `=""` from boolean attributes. Aug 7, 2018
manifest.json auto-converted by polymer-modulizer Jun 23, 2018
package-lock.json 3.0.1 Sep 14, 2018
package.json 3.0.1 Sep 14, 2018
wct.conf.json Update WCT config Jun 5, 2018

README.md

Published on NPM Build status Published on webcomponents.org

<gold-cc-input>

gold-cc-input is a single-line text field with Material Design styling for entering a credit card number. As the user types, the number will be formatted by adding a space every 4 digits.

See: Documentation, Demo.

Usage

Installation

npm install --save @polymer/gold-cc-input

In an html file

<html>
  <head>
    <script type="module">
      import '@polymer/gold-cc-input/gold-cc-input.js';
    </script>
  </head>
  <body>
    <gold-cc-input
          auto-validate
          label="Card number"
          error-message="Enter valid visa or mastercard!"
          card-types='["visa", "mastercard"]'
          value="6011 0000 0000 1233"
          required>
    </gold-cc-input>
  </body>
</html>

In a Polymer 3 element

import {PolymerElement, html} from '@polymer/polymer';
import '@polymer/gold-cc-input/gold-cc-input.js';

class SampleElement extends PolymerElement {
  static get template() {
    return html`
      <gold-cc-input
          auto-validate
          label="Card number"
          error-message="Enter valid visa or mastercard!"
          card-types='["visa", "mastercard"]'
          value="6011 0000 0000 1233"
          required>
      </gold-cc-input>
    `;
  }
}
customElements.define('sample-element', SampleElement);

Contributing

If you want to send a PR to this element, here are the instructions for running the tests and demo locally:

Installation

git clone https://github.com/PolymerElements/gold-cc-input
cd gold-cc-input
npm install
npm install -g polymer-cli

Running the demo locally

polymer serve --npm
open http://127.0.0.1:<port>/demo/

Running the tests

polymer test --npm
You can’t perform that action at this time.