简体   繁体   中英

Birthday input field - auto-adding dots after specific amount of characters

Hey guys, unusual question: I have a input field #birthday that should accept european date format like this. dd.MM.yyyy

I wonder if it is possible to auto apply dots when typed into this field.

Imagine the inputfield is focused and empty. I start typing to numbers and the field autogenerates a dot, again two numbers and a dot is generated.

My aim is to type only numbers without needing to add the dots.

any idea how i could achieve that with jquery or javascript in general?

$('#birhtday').keypress(function() {
    // ?
})

Why not use existing jQuery plugins?

  • Masked input
  • meioMask - I find it nicer because it doesn't use those underscores (but it seems to have some bugs when TAB ing through filled form)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM