Skip to content

Instantly share code, notes, and snippets.

@salsalabs
Last active April 30, 2021 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salsalabs/569dff5cab13cb67e782f40270e9dd24 to your computer and use it in GitHub Desktop.
Save salsalabs/569dff5cab13cb67e782f40270e9dd24 to your computer and use it in GitHub Desktop.
Script to change credit card expiration dates so that they start from the current year. This can be useful on Salsa storefronts.
<!-- BEGIN Change credit card expiration date year to start with the current year. -->
$(document).ready(() => {
const years = 20;
var e = $('select[name=ccExpYear]');
if (e.length == 0) {
return;
}
$('option', e).remove();
e.append('<option value="">Year</option>')
var thisYear = new Date().getFullYear();
Array.from(Array(years).keys()).forEach((v) => {
var y = thisYear + v;
var t = `<option value="${y % 100}">${y}</option>`
e.append($(t));
});
});
<!-- END Change credit card expiration date year to start with the current year. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment