I have made a OTP form which I want to submit via AJAX if all it's input fields are filled in. Is it possible with using class selector $(".tp")
?
$(document).ready(function() {
$(".tp").keyup(function() {
if (this.value.length == 1) {
// this will automatically change the focus as soon as an input is done
$(this).next().focus()
}
})
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="tel" class="tp" maxlength="1">
<input type="tel" class="tp" maxlength="1">
<input type="tel" class="tp" maxlength="1">
<input type="tel" class="tp" maxlength="1">