// 信用卡到期日期格式 (MM/YYYY) FOR 输入时间请帮帮我。
提前致谢 。
<div class="pay-detail">
<label>Exp. Date</label>
<input type="text" class="form-control expdate" placeholder="10/2019" name="expdate" maxlength="7" value="" id="expdate">
</div>
$("body").on("keyup", "#expdate", function (event) {
var foo = $(this).val().split("/").join(""); // remove hyphens
if (foo.length > 0) {
foo = foo.match(new RegExp('.{1,2}', 'g')).join("/");
}
$(this).val(foo);
});
我希望你需要的一切都在这里,正如我回答了你的最后一个问题。
.expiration {
border: 1px solid #bbb;
}
.expiration input {
border: 0;
text-align: center;
outline: 0; /* remove if you want input highlight */
}
<span class="expiration">
<input type="text" name="month" placeholder="MM" maxlength="2" size="2" required="true" />
<span>/</span>
<input type="text" name="year" placeholder="YY" maxlength="2" size="2" required="true" />
</span>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句