when entering in the field, you need to prohibit entering everything except numbers, and entering no more than 13 characters. Only numbers are ready input.value.replace(/[^\d]/g, ''); .
How to prevent the input of more than 13 digits?
when entering in the field, you need to prohibit entering everything except numbers, and entering no more than 13 characters. Only numbers are ready input.value.replace(/[^\d]/g, ''); .
How to prevent the input of more than 13 digits?
input.value.replace(/\D/g,'').substr(0,13) \D means NOT the number. And additionally we take strictly no more than 13 characters.
$('.number').live('keydown', function() { var checkingRegExp = new RegExp(/^(\d){1,13}$/g); return $(this).val().match(checkingRegExp) !== null; }); var checkingRegExp = /^\d{1,13}$/; it is better. - Wiktor Stribiżew 5:52You can use a quantifier in which you specify a range
/^(\d){1,13}$/g Source: https://ru.stackoverflow.com/questions/585454/
All Articles