Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve(billing-ui): Improve credit card entry form #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions public/javascripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,27 @@ jQuery(function($) {
}
}

$('#card-num').payment('formatCardNumber');

var validateDetails = function() {
// set variables for the expiry date validation, cvc validation and expiry date 'splitter'
var cardNum = $('#card-num');
var validateNumber = $.payment.validateCardNumber(cardNum.val());
if (validateNumber) {
// if the cvc is valid add the identified class
cardNum.closest('.form-group').addClass('has-success').removeClass('has-error');
} else {
// remove again if the cvc becomes invalid
cardNum.closest('.form-group').addClass('has-error').removeClass('has-success');
}

}
// this runs the above function every time stuff is entered into the card inputs
$('.paymentInput').bind('change paste keyup', function() {
validateDetails();
});


cardForm.submit(function(e) {
e.preventDefault();

Expand Down Expand Up @@ -55,5 +76,4 @@ jQuery(function($) {
return false;
}
});

});
});
26 changes: 26 additions & 0 deletions public/javascripts/jquery.payment.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading