The SDK includes built-in validation that prevents form submission if fields are invalid.
View all the emitted events here.
Default Behavior
The form will not submit unless all fields pass validation
Invalid fields will display in red (unless overridden in style properties)
Validation occurs on the input
blur
event, as well as after the submit button is clicked.
...
Code Block | ||
---|---|---|
| ||
function customValidate(message) { if (!message.success) { // Handle invalid field showErrorconsole.log(`${message.message);fieldName} - validation failed) } } Netvalve.initTokenFields({ formId: 'paymentForm', onValidate: customValidate }); |
Custom Event Handler
Event Name: field-validation
Code Block | ||
---|---|---|
| ||
window.addEventListener('field-validation', (event) => {
const message = event.detail;
// Handle validation result
}); |
...
Code Block | ||
---|---|---|
| ||
{
type: 'field-validation',
fieldName: 'cardNumber' | 'cardCvv' | 'cardExpiry',
success: boolean,
message: string,
paymentToken: string
} |
...
In rare cases where tokenization fails on the Netvalve server, the form will not submit even if the validation . You can handle these cases using the tokenization event:
Event Name: field-tokenization
Code Block | ||
---|---|---|
| ||
window.addEventListener('field-tokenization', (event) => { const result = event.detail; // result structure: { type: 'field-tokenization', fieldName: 'cardNumber' | 'cardCvv' | 'cardExpiry', success: boolean, message: string, paymentToken: string } if (!result.success) { showError('Failed to process card details.'); } }); |
See Also
https://netvalve.atlassian.net/wiki/spaces/950272/pages/edit-v2/147947686/
https://hpitdxb.atlassian.net/wiki/spaces/215580674/pages/edit-v2/1136361488/
https://hpitdxb.atlassian.net/wiki/spaces/215580674/pages/edit-v2/1136197640/
https://hpitdxb.atlassian.net/wiki/spaces/215580674/pages/edit-v2/1136492569/
https://hpitdxb.atlassian.net/wiki/spaces/215580674/pages/edit-v2/1136656400/