You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Parses a credit card expiry in the form of MM/YYYY, returning an object containing the `month` and `year`. Shorthand years, such as `13` are also supported (and converted into the longhand, e.g. `2013`).
This function doesn't perform any validation of the month or year; use `payform.validateCardExpiry(month, year)` for that.
130
156
131
-
### payform.cards
132
-
133
-
Array of objects that describe valid card types. Each object should contain the following fields:
134
-
135
-
```javascript
136
-
{
137
-
// Card type, as returned by payform.parseCardType.
138
-
type:'mastercard',
139
-
// Regex used to identify the card type. For the best experience, this should be
140
-
// the shortest pattern that can guarantee the card is of a particular type.
141
-
pattern:/^5[0-5]/,
142
-
// Array of valid card number lengths.
143
-
length: [16],
144
-
// Array of valid card CVC lengths.
145
-
cvcLength: [3],
146
-
// Boolean indicating whether a valid card number should satisfy the Luhn check.
147
-
luhn:true,
148
-
// Regex used to format the card number. Each match is joined with a space.
149
-
format:/(\d{1,4})/g
150
-
}
151
-
```
152
-
153
-
When identifying a card type, the array is traversed in order until the card number matches a `pattern`. For this reason, patterns with higher specificity should appear towards the beginning of the array.
154
-
155
-
## Browser `<input>` Helpers
157
+
### Browser `<input>` formatting helpers
156
158
157
159
These methods are specifically for use in the browser to attach `<input>` formatters.
158
160
159
-
### payform.cardNumberInput(input)
161
+
####payform.cardNumberInput(input)
160
162
161
163
Formats card numbers:
162
164
@@ -172,7 +174,7 @@ var input = document.getElementById('ccnum');
172
174
payform.cardNumberInput(input);
173
175
```
174
176
175
-
### payform.expiryInput(input)
177
+
####payform.expiryInput(input)
176
178
177
179
Formats card expiry:
178
180
@@ -183,11 +185,11 @@ Formats card expiry:
183
185
Example:
184
186
185
187
```javascript
186
-
var input =document.getElementById('ccnum');
188
+
var input =document.getElementById('expiry');
187
189
payform.expiryInput(input);
188
190
```
189
191
190
-
### payform.cvcInput(input)
192
+
####payform.cvcInput(input)
191
193
192
194
Formats card CVC:
193
195
@@ -197,17 +199,39 @@ Formats card CVC:
197
199
Example:
198
200
199
201
```javascript
200
-
var input =document.getElementById('ccnum');
202
+
var input =document.getElementById('cvc');
201
203
payform.cvcInput(input);
202
204
```
203
205
204
-
## Building
206
+
### Custom Cards
207
+
208
+
#### payform.cards
205
209
206
-
Run `npm run build`
210
+
Array of objects that describe valid card types. Each object should contain the following fields:
211
+
212
+
```javascript
213
+
{
214
+
// Card type, as returned by payform.parseCardType.
215
+
type:'mastercard',
216
+
// Regex used to identify the card type. For the best experience, this should be
217
+
// the shortest pattern that can guarantee the card is of a particular type.
218
+
pattern:/^5[0-5]/,
219
+
// Array of valid card number lengths.
220
+
length: [16],
221
+
// Array of valid card CVC lengths.
222
+
cvcLength: [3],
223
+
// Boolean indicating whether a valid card number should satisfy the Luhn check.
224
+
luhn:true,
225
+
// Regex used to format the card number. Each match is joined with a space.
226
+
format:/(\d{1,4})/g
227
+
}
228
+
```
229
+
230
+
When identifying a card type, the array is traversed in order until the card number matches a `pattern`. For this reason, patterns with higher specificity should appear towards the beginning of the array.
207
231
208
-
## Running tests
232
+
## Development
209
233
210
-
Run `npm test`
234
+
Please see [CONTRIBUTING.md](https://github.com/jondavidjohn/payform/blob/develop/CONTRIBUTING.md).
0 commit comments