이단교단 기타 선택시 직접 입력 추가

This commit is contained in:
peregr1nus
2025-12-12 16:17:09 +09:00
parent 8ab14e951a
commit a3c8a6d738
2 changed files with 51 additions and 1 deletions

View File

@@ -42,6 +42,11 @@
</select>
</div>
<div class="form-group" id="cultOtherGroup" style="display: none;">
<label for="cult_other">이단교단 직접 입력 *</label>
<input type="text" id="cult_other" name="cult_other" value="{{ basic_info.get('cult_other', '') }}" placeholder="이단교단명을 입력해주세요">
</div>
<div class="form-actions">
<button type="submit" class="btn btn-primary">다음 단계</button>
</div>
@@ -51,9 +56,45 @@
{% block scripts %}
<script>
// 이단교단 선택에 따라 직접 입력 필드 표시/숨김
document.getElementById('cult').addEventListener('change', function() {
const cultOtherGroup = document.getElementById('cultOtherGroup');
const cultOtherInput = document.getElementById('cult_other');
if (this.value === '기타 (위 선택지에 없을 경우)') {
cultOtherGroup.style.display = 'block';
cultOtherInput.required = true;
} else {
cultOtherGroup.style.display = 'none';
cultOtherInput.required = false;
cultOtherInput.value = '';
}
});
// 페이지 로드 시 초기 상태 설정
document.addEventListener('DOMContentLoaded', function() {
const cultSelect = document.getElementById('cult');
if (cultSelect.value === '기타 (위 선택지에 없을 경우)') {
document.getElementById('cultOtherGroup').style.display = 'block';
document.getElementById('cult_other').required = true;
}
});
document.getElementById('step1Form').addEventListener('submit', async function(e) {
e.preventDefault();
// '기타' 선택 시 직접 입력 필드 검증
const cultSelect = document.getElementById('cult');
const cultOtherInput = document.getElementById('cult_other');
if (cultSelect.value === '기타 (위 선택지에 없을 경우)') {
if (!cultOtherInput.value.trim()) {
alert('이단교단명을 직접 입력해주세요.');
cultOtherInput.focus();
return;
}
}
const formData = new FormData(this);
const data = Object.fromEntries(formData);