From 57ed3c3bb3781d8816ba78b8935b8f4e91ffd657 Mon Sep 17 00:00:00 2001 From: Volodymyr Kotulskiy Date: Fri, 13 May 2016 15:12:20 +0300 Subject: [PATCH] You have ti allow users to use Backspace, Delete and Arrow keys even if there is 4 digits in the field --- src/format.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/format.js b/src/format.js index 68455cf..46d9944 100644 --- a/src/format.js +++ b/src/format.js @@ -177,8 +177,12 @@ angular.module('angularPayments') _formatCVC = function(e){ $target = angular.element(e.currentTarget); digit = String.fromCharCode(e.which); - - if (!/^\d+$/.test(digit) && !e.meta && e.keyCode >= 46) { + + if (e.keyCode == 46 || e.keyCode == 8||(e.keyCode >=37 && e.keyCode <=40)) { + return; + } + + if (!/^\d+$/.test(digit) && !e.meta && e.which >= 46) { e.preventDefault(); return; }