@@ -38,6 +38,10 @@ npm install payform --save
3838``` javascript
3939var payform = require (' payform' );
4040
41+ // Format input for card number entry
42+ var input = document .getElementById (' ccnum' );
43+ payform .cardNumberInput (input)
44+
4145// Validate a credit card number
4246payform .validateCardNumber (' 4242 4242 4242 4242' ); // => true
4347
@@ -53,6 +57,10 @@ require.config({
5357});
5458
5559require ([" payform" ], function (payform ) {
60+ // Format input for card number entry
61+ var input = document .getElementById (' ccnum' );
62+ payform .cardNumberInput (input)
63+
5664 // Validate a credit card number
5765 payform .validateCardNumber (' 4242 4242 4242 4242' ); // => true
5866
@@ -71,6 +79,10 @@ bower install payform --save
7179``` html
7280<script src =" path/to/payform/dist/payform.js" ></script >
7381<script >
82+ // Format input for card number entry
83+ var input = document .getElementById (' ccnum' );
84+ payform .cardNumberInput (input)
85+
7486 // Validate a credit card number
7587 payform .validateCardNumber (' 4242 4242 4242 4242' ); // => true
7688
@@ -79,6 +91,26 @@ bower install payform --save
7991 </script >
8092```
8193
94+ ### jQuery Plugin (also supports Zepto)
95+
96+ This library also includes a jquery plugin. The primary ` payform ` object
97+ can be found at ` $.payform ` , and there are jquery centric ways to utilize the [ browser
98+ input formatters.] ( #browser-input-formatting-helpers )
99+
100+ ``` html
101+ <script src =" path/to/payform/dist/jquery.payform.js" ></script >
102+ <script >
103+ // Format input for card number entry
104+ $ (' input.ccnum' ).payform (' formatCardNumber' );
105+
106+ // Validate a credit card number
107+ $ .payform .validateCardNumber (' 4242 4242 4242 4242' ); // => true
108+
109+ // Get card type from number
110+ $ .payform .parseCardType (' 4242 4242 4242 4242' ); // => 'visa'
111+ </script >
112+ ```
113+
82114## API
83115
84116### General Formatting and Validation
@@ -169,8 +201,12 @@ This function doesn't perform any validation of the month or year; use `payform.
169201
170202These methods are specifically for use in the browser to attach ` <input> ` formatters.
171203
204+ (alternate [ jQuery Plugin] ( #jquery-plugin ) syntax is also provided)
205+
172206#### payform.cardNumberInput(input)
173207
208+ _ jQuery plugin:_ ` $(...).payform('formatCardNumber') `
209+
174210Formats card numbers:
175211
176212* Includes a space between every 4 digits
@@ -187,6 +223,8 @@ payform.cardNumberInput(input);
187223
188224#### payform.expiryInput(input)
189225
226+ _ jQuery plugin:_ ` $(...).payform('formatCardExpiry') `
227+
190228Formats card expiry:
191229
192230* Includes a ` / ` between the month and year
@@ -202,6 +240,8 @@ payform.expiryInput(input);
202240
203241#### payform.cvcInput(input)
204242
243+ _ jQuery plugin:_ ` $(...).payform('formatCardCVC') `
244+
205245Formats card CVC:
206246
207247* Restricts length to 4 numbers
@@ -214,6 +254,19 @@ var input = document.getElementById('cvc');
214254payform .cvcInput (input);
215255```
216256
257+ #### payform.numericInput(input)
258+
259+ _ jQuery plugin:_ ` $(...).payform('formatNumeric') `
260+
261+ General numeric input restriction.
262+
263+ Example:
264+
265+ ``` javascript
266+ var input = document .getElementById (' numeric' );
267+ payform .numericInput (input);
268+ ```
269+
217270### Custom Cards
218271
219272#### payform.cards
0 commit comments