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
Copy file name to clipboardExpand all lines: README.md
+44-11Lines changed: 44 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -323,7 +323,8 @@ Along with Collect Element we can define other options which takes a object of o
323
323
constoptions= {
324
324
required:false, // Optional, indicates whether the field is marked as required. Defaults to 'false'.
325
325
enableCardIcon:true, // Optional, indicates whether card icon should be enabled (only applicable for CARD_NUMBER ElementType).
326
-
format:String, // Optional, format for the element (only applicable currently for EXPIRATION_DATE ElementType).
326
+
format:String, // Optional, format for the element.
327
+
translation: {}, // Optional, indicates the allowed data type value for format.
327
328
enableCopy:false, // Optional, enables the copy icon in collect and reveal elements to copy text to clipboard. Defaults to 'false').
328
329
allowedFileType: string[], // Optional, allowed extensions for the file to be uploaded.
329
330
cardMetadata: {}, // Optional, metadata to control card number element behavior. (only applicable for CARD_NUMBER ElementType).
@@ -336,25 +337,57 @@ const options = {
336
337
337
338
-`enableCardIcon` parameter indicates whether the icon is visible for the CARD_NUMBER element, defaults to true
338
339
339
-
-`format` parameter takes string value and indicates the format pattern applicable to the element type, It's currently only applicable to `EXPIRATION_DATE` and `EXPIRATION_YEAR` element types.
340
340
341
341
-`enableCopy` parameter indicates whether the copy icon is visible in collect and reveal elements.
342
342
343
343
-`allowedFileType` parameter indicates the allowedFileType extensions to be uploaded.
344
344
345
-
The values that are accepted for `EXPIRATION_DATE` are
345
+
-`format`: A string value that indicates the format pattern applicable to the element type.
346
+
Only applicable to EXPIRATION_DATE, CARD_NUMBER, EXPIRATION_YEAR, and INPUT_FIELD elements.
346
347
347
-
-`MM/YY` (default)
348
-
-`MM/YYYY`
349
-
-`YY/MM`
350
-
-`YYYY/MM`
348
+
- For INPUT_FIELD elements,
349
+
- the length of `format` determines the expected length of the user input.
350
+
- if `translation` isn't specified, the `format` value is considered a string literal.
351
351
352
-
The values that are accepted for `EXPIRATION_YEAR` are
352
+
`translation`: An object of key value pairs, where the key is a character that appears in `format` and the value is a simple regex pattern of acceptable inputs for that character. Each key can only appear once. Only applicable for INPUT_FIELD elements.
353
353
354
-
-`YY` (default)
355
-
-`YYYY`
354
+
Accepted values by element type:
355
+
356
+
| Element type |`format` and `translation` values | Examples |
| INPUT_FIELD | <li>`format`: A string that matches the desired output, with placeholder characters of your choice.</li><li>`translation`: An object of key/value pairs. Defaults to `{"X": "[0-9]"}`</li> | With a `format` of `+91 XXXX-XX-XXXX` and a `translation` of `{"X": "[0-9]"}`, user input of "1234121234" displays as "+91 1234-12-1234". |
362
+
363
+
364
+
**Note:** If `format` isn't specified or receives an invalid value, it uses the element type's default value.
365
+
366
+
**Collect Element Options examples for INPUT_FIELD**
367
+
368
+
Example 1
369
+
```js
370
+
constoptions= {
371
+
format:'+91 XXXX-XX-XXXX',
372
+
translation: { 'X':'[0-9]' }
373
+
}
374
+
```
375
+
376
+
User input:"1234121234"
377
+
Value displayed inINPUT_FIELD:"+91 1234-12-1234"
378
+
379
+
Example 2
380
+
```js
381
+
const options = {
382
+
required: true,
383
+
enableCardIcon: true,
384
+
format: 'AY XX-XXX-XXXX',
385
+
translation: { 'X': '[0-9]', 'Y': '[A-Z]' }
386
+
}
387
+
```
388
+
User input:"B123412124"
389
+
Value displayed inINPUT_FIELD:"AB 12-341-2124"
356
390
357
-
`NOTE`: If not specified or invalid value is passed to the `format` then it takes default value.
358
391
359
392
-`cardMetadata`: An object of metadata keys to control card number element behavior. It supports an optional key called `scheme`, which accepts an array of Skyflow accept card types based on which SDK will display card brand choice dropdown in the card number element. `CardType` is an enumwith all skyflow supported card schemes.
0 commit comments