Answer the question
In order to leave comments, you need to log in
How can I do a validation check?
Moderators, correct me pzh
All shalom! I want to validate the fields, I have a form that works step by step, how can I do if the field is empty then do not show it on the next step?
I need everything to validate except the input with the last name
Here is the jquery code
$(document).ready(function () {
var steps = $('form').children('.tab');
$(steps[0]).show();
var current_step = 0;
$('form button.next').click(function () {
if (current_step >= steps.length - 2) {
$(this).hide();
$("form button.signup").show();
}
current_step++;
$(steps).hide();
$(steps[current_step]).show();
});
});
<form id="regForm" action="" method="post">
<div class="tab">
<h4>Ваш номер телефона</h4>
<p>Пожалуйста, подтвердите код страны и введите номер телефона.</p>
<div class="error">
<span>Неверный номер телефона</span>
</div>
<p><input type="text" name="phone" id="phone" placeholder="+380"></p>
</div>
<div class="tab">
<h4 id="title-phone"></h4>
<p>Мы отправили вам сообщение с кодом активации на ваш телефон. Пожалуйста, введите его ниже.</p>
<div class="error">
<span>Неверный код активации</span>
</div>
<p><input type="text" name="code" placeholder="Ваш код"></p>
</div>
<div class="tab">
<h4>Ваша информация</h4>
<p>Пожалуйста, введите свое имя и загрузить фотографию.</p>
<div class="photo">
<span></span>
</div>
<div class="error">
<span>Введите ваше имя</span>
</div>
<p><input type="text" placeholder="Имя" id="firstname"></p>
<p><input placeholder="Фамилия (не обязательно)"></p>
</div>
<button type="button" class="next">продолжить</button>
<button type="button" class="signup" style="display: none;">ЗАРЕГИСТРИРОВАТЬСЯ</button>
</form>
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