[英]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. 嗨,大家好,一个不寻常的问题:我有一个输入字段#birthday,应该接受这样的欧洲日期格式。 dd.MM.yyyy
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? 任何想法,我怎么能用一般的jQuery或javascript实现呢?
$('#birhtday').keypress(function() {
// ?
})
Why not use existing jQuery plugins? 为什么不使用现有的jQuery插件?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.