I am using braintree in my Rails application. Integrated using gem 'braintree'. I use a dropin UI which is implemented like this:
braintree.dropin.create({
authorization: client_token,
container: '#bt-dropin'
}, function (createErr, instance) {
form.addEventListener('submit', function (event) {
event.preventDefault();
instance.requestPaymentMethod(function (err, payload) {
if (err) {
console.log('Error', err);
return;
}
// Add the nonce to the form and submit
document.querySelector('#nonce').value = payload.nonce;
form.submit();
});
});
});
This works fine. But i need to catch errors if any and disable submit button if the cursor is moved out from the inputbox. Is there any solution for that? Please help.