Answer the question
In order to leave comments, you need to log in
Symbols are not deleted on android 4.4.4?
$(function() {
$(".cardnumber").mask("9999-9999-9999-9999-99");
$(".cardnumber").on("blur", function() {
var last = $(this).val().substr($(this).val().indexOf("-") + 1);
if (last.length == 5) {
var move = $(this).val().substr($(this).val().indexOf("-") + 1, 1);
var lastfour = last.substr(1, 4);
var first = $(this).val().substr(0, 9);
$(this).val(first + move + '-' + lastfour);
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="tel" class="cardnumber" name="cardcode" pattern="[0-9]{4}\s[0-9]{4}\s[0-9]{4}\s[0-9]{4}" placeholder="XXXX XXXX XXXX XXXX XXXX">
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question