• France
status page
Demo shops
assistance
FAQContact support
Search
Categories
Tags
docs.
France
Spain
Europe (English)
India
Homepage
Use cases
Create a payment
Create an installment payment
Create a multi-card (split) payment
Create a payment by Alias (Token)
Create a payment link
Create a recurring payment
Manage subscriptions
Manage your transactions (refund, cancel...)
Analyze your reports
API docs
Embedded Form
REST API
Hosted payment
Mobile payment
File exchange
SDD mandates by REST API
Snippets
Payment methods
Plugins
Marketplace
Guides
Merchant Back Office
Back Office Expert
Functional guides

KR.validateForm()

Description

This method checks locally if the form is valid. It returns a promise:.

  • then() is called when the form is valid. result will be set to null.
  • catch() is called when the form is invalid. result contains the details of the error.

Example of integration

You must implement the function described in the header of your payment page, after loading our main JavaScript library (kr-payment-form.min.js), as well as the associated style sheets.

KR.validateForm().then( ({KR, result}) => {

    /* there is no error */
    /* result == null */
    }

)
.catch( ({KR, result}) => {

    /* Get the error message */
    var code = result.errorCode;
    var message = result.errorMessage;
    var myMessage = code + ": " + message;
    console.log(myMessage);

    /* if you have defined a callback using      */
    /* result.onError(), you can trigger it calling: */
    return result.doOnError();
    }

);

Once you have intercepted the errors, you can trigger the KR.onError() event manually by calling result.doOnError();.

Jobs
Legal
GDPR
25.18-1.11