Inputmask: Credit Card Expiration Date

Created on 13 Jun 2012  路  9Comments  路  Source: RobinHerbots/Inputmask

Hi Robin,
I need a mask like mm/yy (2 digits for month, 2 digits for year)

perfect:
date should be now or in the future

How can I set the cardinality for years to 2 digits?

Most helpful comment

@christianhaller Here, hold my tequila:

$('#expires_mmyy').inputmask({alias: 'datetime', inputFormat: 'mm/yy'});

@yevt @sancao
Hope that helps others trying to figure out how to work with formatting _datetime_.

All 9 comments

Hi Christian,

You have to create a new defintion or adjust the defintion for y (year).
You can find more info by looking at the date.extentions.

best regards,

Robin

2012/6/13 Christian Haller <
[email protected]

Hi Robin,
I need a mask like mm/yy (2 digits for month, 2 digits for year)

perfect:
date should be now or in the future

How can I set the cardinality for years to 2 digits?


Reply to this email directly or view it on GitHub:
https://github.com/RobinHerbots/jquery.inputmask/issues/64

Thx Robin.
I made it :)

Maybe you can share your code so others can use it too?

2012/6/13 Christian Haller <
[email protected]

Thx Robin.
I made it :)


Reply to this email directly or view it on GitHub:

https://github.com/RobinHerbots/jquery.inputmask/issues/64#issuecomment-6303543

Sorry, I forgot this. I will post it today :)

@christianhaller Maybe now?

could you pls to share your code @christianhaller, i also need one like that?

@christianhaller Here, hold my tequila:

$('#expires_mmyy').inputmask({alias: 'datetime', inputFormat: 'mm/yy'});

@yevt @sancao
Hope that helps others trying to figure out how to work with formatting _datetime_.

@RobinHerbots - any input in regards to adding a limited year range on this code...

$('#expires_mmyy').inputmask({alias: 'datetime', inputFormat: 'mm/yy'});

OH WOWZERS! Got date range to work!

$('#expires_mmyy').inputmask({
   alias: 'datetime', 
   inputFormat: 'mm/yy'
   min: '08/19',
   max: '01/30'
});

lets say you want a 10 year date range from today's date dynamically...

include the moment.js library...

https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js

then...

min: moment().add(1, 'M').format('MM/YY'),
max: moment().add(10, 'Y').format('MM/YY')
Was this page helpful?
0 / 5 - 0 ratings

Related issues

RobinHerbots picture RobinHerbots  路  4Comments

osaris picture osaris  路  6Comments

webmastervinay picture webmastervinay  路  4Comments

hrolick-git picture hrolick-git  路  5Comments

pikaclint picture pikaclint  路  3Comments