Skip to content

Instantly share code, notes, and snippets.

@catindev
Created September 14, 2017 06:32
Show Gist options
  • Select an option

  • Save catindev/8f48a7340fdb05e4c0309cb36b24795d to your computer and use it in GitHub Desktop.

Select an option

Save catindev/8f48a7340fdb05e4c0309cb36b24795d to your computer and use it in GitHub Desktop.
Проверяем выбран ли тип пользователя
<!-- 1. Добавляем id контейнеру с радиокнопками для выбора пользователя -->
<div class="form-group" id="reg_type">
...
</div>
<!-- 2. Под этот контейнер ставим сообщение об ошибке -->
<div class="alert alert-danger" style="display:none" id="regTypeAlert">
<strong>Не выбран тип пользователя</strong><br/>
Без него вы не сможете заполнить данные для участия в мероприятиях.
</div>
<!-- 3. Джаваскрипт для этого всего -->
<script>
$('#submit_reg').on('click', function (event) {
if ($('input[name=reg_type]:checked').length === 0) {
event.preventDefault();
$('#regTypeAlert').slideDown();
}
});
$('#reg_type label').on('click', function (event) {
$('#regTypeAlert').hide();
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment