<vega-form>
<vega-input-credit-card
data-vega-form="creditCard1"
value="4111 1111 1111 1111"
hide-card-number-on-blur = "true"
/>
<vega-input-credit-card
data-vega-form="creditCard2"
value="5555 5555 5555 4444"
/>
<vega-input-credit-card
data-vega-form="creditCard3"
value="6011 1111 1111 1117"
/>
<vega-input-credit-card
data-vega-form="creditCard4"
value="3782 822463 10006"
/>
</vega-form>
The Input Credit Card component is a variant on the standard input component, designed to allow credit card information. Initially the image will be a generic placeholder until the user inputs a credit card number. It should then automatically prepopulate the correct credit card brand image, identifiable by the card number input.
Name | Description | Default | |
---|---|---|---|
label | The label of input credit card text |
- | |
value | The preset value for a input credit card string |
||
required | Indicates whether the vega-input-credit-card is required.boolean |
false | |
auto-validation | Indicates whether to automatically validate the user’s input. | true | |
validation-rules | Custom validation rules you would like to attach to the input credit cardArray<{canEvaluate: (input: string, status: FormFieldStatusMeta, statusChanged: (keyof FormFieldStatusMeta)[]) => boolean, shouldShowError: (status: FormFieldStatusMeta, statusChanged: (keyof FormFieldStatusMeta)[]) => boolean, evaluate: (input: string) => EvaluateResult}> |
||
placeholder | A placeholder string indicating the input credit card format string |
||
disabled | Indicating if the input credit card field is disabled. boolean |
false | |
hint | A prompt message to supplement the expected value of the input credit card field. string |
||
size | The size of the input credit card field.default small |
default | |
hide-card-number-on-blur | Sets the card number to be X except the last part of the mask on blur for supported card types boolean |
true |
<vega-form>
<vega-input-credit-card
data-vega-form="creditCard"
label="credit-card-label"
value="credit-card-value"
required="true"
auto-validation="true"
validation-rules=object
placeholder=""
disabled=false
hint=""
size="default"
hide-card-number-on-blur='true'
>
</vega-input-credit-card>
</vega-form>
validationRules
PropertyNote: If you wish to use the ValidationRules
property, place the component into vega-form
and set the data-vega-form property
for the component.
Setting the validationRules property with
element.setAttribute('validationRules', {...})
will not properly trigger validation. We recommend that you set it by usingelement.validationRules = {...}
.
The following preset validation rules are controlled by their corresponding boolean properties:
''
.vegaChange
vega-input-credit-card
is changed.React
<VegaInputCreditCard onVegaChange={ (e) => { console.log(e.currentTarget.value) } } ... ></VegaInputCreditCard>
Vue.js
<vega-input-credit-card @vegachange="method" ...></vega-input-credit-card>
JavaScript
document.getElementById("credit_card_id").addEventListener("vegaChange", (e) => {
console.log(e.currentTarget.value) })
vegaValidate
vega-input-credit-card
is changed.React
<VegaInputCreditCard onVegaValidate={ (e) => { console.log(e.currentTarget.isValid) } } ... ></VegaInputCreditCard>
Vue.js
<vega-input-credit-card @vegavalidate="method" ...></vega-input-credit-card>
JavaScript
document.getElementById("credit_card_id").addEventListener("vegaValidate", (e) => {
console.log(e.currentTarget.isValid) })
vegaBlur
vega-input-credit-card
loses focus. React
<!-- React -->
<VegaInputCreditCard onVegaBlur={ (e) => { console.log(e.currentTarget.value) } } ... ></VegaInputCreditCard>
Vue.js
<vega-input-credit-card @vegablur="method" ...></vega-input-credit-card>
JavaScript
document.getElementById("credit_card_id").addEventListener("vegaBlur", (e) => {
console.log(e.currentTarget.value) })
vegaFocus
vega-input-credit-card
is focused.React
<VegaInputCreditCard onVegaFocus={ (e) => { console.log(e.currentTarget.value) } } ... ></VegaInputCreditCard>
Vue.js
<vega-input-credit-card @vegafocus="method" ...></vega-input-credit-card>
JavaScript
document.getElementById("credit_card_id").addEventListener("vegaFocus", (e) => {
console.log(e.currentTarget.value) })