$("#confirm-button-next").on("click", function() {
$("div.error").remove();
if ($("#order_fio").val().length < 1) {
$("#order_fio").after('<div class="error" style="margin-top:15px;"><font color="red">Заполните поле "Ф.И.О"!</font></div>');
setTimeout(function() {
$("div.error").remove();
}, 5000);
return false;
}
if ($("#order_phone").val().length < 1) {
$("#order_phone").after('<div class="error" style="margin-top:15px;"><font color="red">Заполните поле "Моб. номер"!</font></div>');
setTimeout(function() {
$("div.error").remove();
}, 5000);
return false;
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="field field--optional field--half" data-address-field="first_name">
<div class="field__input-wrapper"><label class="field__label field__label--visible" for="checkout_shipping_address_first_name">Ф.И.О</label>
<input name="order_fio" placeholder="Ф.И.О" autocomplete="shipping given-name" data-backup="first_name" class="field__input" size="30" type="text" id="order_fio">
</div>
</div>
<div class="field field--required field--half" data-address-field="last_name">
<div class="field__input-wrapper"><label class="field__label field__label--visible" for="checkout_shipping_address_last_name">Моб. номер</label>
<input name="order_phone" placeholder="Моб. номер" autocomplete="shipping family-name" data-backup="last_name" class="field__input" aria-required="true" size="30" type="text" name="checkout[shipping_address][last_name]" id="order_phone">
</div>
</div>
<button style="margin-top:15px;" type="submit" name="submitdata" id="confirm-button-next" name="button" type="submit" class="step__footer__continue-btn btn">
<span class="btn__content">Оформить заказ</span>
<i class="btn__spinner icon icon--button-spinner"></i>
</button>
Подскажите, как сделать так чтобы в поле "Ф.И.О" нельзя было вводить цифры, а в поле "Моб. номер" буквы. И ещё кое что, как сделать чтобы при ошибке вместе с сообщением "Заполните поле" обводилось поле красным цветом?
keypress, keyup, keydown
и вырезайте цифры, а в мобиле буквы.