{"action":"created","issue":{"url":"https://api.github.com/repos/formvalidation/support/issues/439","labels_url":"https://api.github.com/repos/formvalidation/support/issues/439/labels{/name}","comments_url":"https://api.github.com/repos/formvalidation/support/issues/439/comments","events_url":"https://api.github.com/repos/formvalidation/support/issues/439/events","html_url":"https://github.com/formvalidation/support/issues/439","id":124166682,"number":439,"title":"Validating credit card expiration date using two separate fields","user":{"login":"laxman4434","id":7378501,"avatar_url":"https://avatars.githubusercontent.com/u/7378501?v=3","gravatar_id":"","url":"https://api.github.com/users/laxman4434","html_url":"https://github.com/laxman4434","followers_url":"https://api.github.com/users/laxman4434/followers","following_url":"https://api.github.com/users/laxman4434/following{/other_user}","gists_url":"https://api.github.com/users/laxman4434/gists{/gist_id}","starred_url":"https://api.github.com/users/laxman4434/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laxman4434/subscriptions","organizations_url":"https://api.github.com/users/laxman4434/orgs","repos_url":"https://api.github.com/users/laxman4434/repos","events_url":"https://api.github.com/users/laxman4434/events{/privacy}","received_events_url":"https://api.github.com/users/laxman4434/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/formvalidation/support/labels/question","name":"question","color":"cc317c"},{"url":"https://api.github.com/repos/formvalidation/support/labels/update%20document","name":"update document","color":"5319e7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-29T05:47:35Z","updated_at":"2015-12-29T16:43:19Z","closed_at":null,"body":" Hi nghuuphuoc,\r\n\r\nhttp://formvalidation.io/examples/validating-credit-card-expiration-date/\r\n\r\nWhile using credit card expiration date using two separate fields, is it possible to allow only last two digits in the year field instead of four digits\r\n\r\nThanks in advance"},"comment":{"url":"https://api.github.com/repos/formvalidation/support/issues/comments/167827727","html_url":"https://github.com/formvalidation/support/issues/439#issuecomment-167827727","issue_url":"https://api.github.com/repos/formvalidation/support/issues/439","id":167827727,"user":{"login":"nghuuphuoc","id":4226036,"avatar_url":"https://avatars.githubusercontent.com/u/4226036?v=3","gravatar_id":"","url":"https://api.github.com/users/nghuuphuoc","html_url":"https://github.com/nghuuphuoc","followers_url":"https://api.github.com/users/nghuuphuoc/followers","following_url":"https://api.github.com/users/nghuuphuoc/following{/other_user}","gists_url":"https://api.github.com/users/nghuuphuoc/gists{/gist_id}","starred_url":"https://api.github.com/users/nghuuphuoc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nghuuphuoc/subscriptions","organizations_url":"https://api.github.com/users/nghuuphuoc/orgs","repos_url":"https://api.github.com/users/nghuuphuoc/repos","events_url":"https://api.github.com/users/nghuuphuoc/events{/privacy}","received_events_url":"https://api.github.com/users/nghuuphuoc/received_events","type":"User","site_admin":false},"created_at":"2015-12-29T16:43:19Z","updated_at":"2015-12-29T16:43:19Z","body":"You can use the `transformer` option. The idea is that using this option to transform a two digits year number into a four digits year number:\r\n\r\n```javascript\r\n$(document).ready(function() {\r\n    $('#paymentForm').formValidation({\r\n        framework: 'bootstrap',\r\n        icon: {\r\n            ...\r\n        },\r\n        fields: {\r\n            expMonth: {\r\n                row: '.col-xs-3',\r\n                validators: {\r\n                    // ... The same code as seen in the example\r\n                }\r\n            },\r\n            expYear: {\r\n                row: '.col-xs-3',\r\n                // HERE is the new code\r\n                transformer: function($field, validatorName, validator) {\r\n                \tvar year = parseInt($field.val(), 10);\r\n                  if (isNaN(year)) {\r\n                  \treturn year;\r\n                  } else {\r\n                  \t// Add 2000 to year\r\n                  \treturn 2000 + year;\r\n                  }\r\n                },\r\n                validators: {\r\n                    // ... The same code as seen in the example\r\n                }\r\n            }\r\n        }\r\n    });\r\n});\r\n```\r\n\r\nI made a fiddle for this at http://jsfiddle.net/nghuuphuoc/juavhwo0/2/\r\n\r\n![credit-card](https://cloud.githubusercontent.com/assets/4226036/12037886/c122f510-ae85-11e5-834c-cfecae15d35f.gif)\r\n\r\n__IMPORTANT__\r\nYou should take a look at the [Modifying the value before validating](http://formvalidation.io/examples/modifying-value-before-validating/) example to see how powerful the `transformer` option is."}}