| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- let fileArray = [];
- function openApply() {
- const manual = document.getElementById('advice_manual');
- const manualHead = document.getElementById('advice_manual_header');
- const apply = document.getElementById('advice_apply');
- const applyHead = document.getElementById('advice_apply_header');
- manual.style.display = 'none';
- manualHead.style.display = 'none';
- apply.style.display = 'block';
- applyHead.style.display = 'block';
- }
- async function dupleNickCheck() {
- const nicknameInput = document.getElementById('lg_nickname');
- const nickname = nicknameInput.value;
- if (nickname.length > 0) {
- const res = await axios.post('api/v1/board/nickname', {nickname})
- if (res.data.checkCount > 0) {
- alert('중복된 닉네임입니다.');
- nicknameInput.value = null;
- } else {
- alert('사용 가능한 닉네임입니다.');
- nicknameInput.disabled = true;
- }
- }
- }
- function subForm() {
- if (validationCheck()) {
- const form = document.getElementById('logi_ad_form')
- const formData = new FormData(form);
- formData.append('userName', document.getElementById('lg_name').value);
- formData.append('phoneNum', document.getElementById('lg_phone').value);
- formData.append('email', document.getElementById('lg_email').value);
- formData.append('nickname', document.getElementById('lg_nickname').value);
- if (fileArray.length > 0) {
- console.log(fileArray)
- for (let file of fileArray) {
- formData.append('files', file[0]);
- }
- }
- axios.post('api/v1/board/add', formData)
- .then(function (res) {
- alert('신청이 완료되었습니다.');
- clearApply();
- clearModal();
- })
- .catch(function (e) {
- console.log(e)
- })
- }
- }
- function clearApply() {
- const div = document.getElementById('advice_apply');
- const inputElements = div.querySelectorAll('input');
- const btnElements = div.querySelectorAll('button');
- inputElements.forEach(input => {
- input.value = '';
- });
- btnElements.forEach(btn=>{
- btn.disabled = false;
- })
- const ul = document.getElementById('lg_file_list');
- ul.innerHTML = '';
- fileArray = [];
- }
- function clearModal() {
- const form = document.getElementById('check_info');
- const inputElements = form.querySelectorAll('input');
- inputElements.forEach(input => {
- input.value = '';
- });
- const timer = document.getElementById('timer');
- timer.innerHTML = '';
- }
- /*
- document.getElementById('lg_file').addEventListener('change', (event)=>{
- const files = event.target.files;
- let html = '';
- if (fileArray.length > 5) {
- alert('파일은 5개까지 업로드 가능합니다.')
- } else {
- fileArray.push(files);
- }
- const ul = document.getElementById('lg_file_list');
- const textNode = document.createTextNode(files[0].name);
- const li = document.createElement('li');
- li.setAttribute('class', 'list-group-item')
- li.appendChild(textNode);
- ul.appendChild(li);
- })
- */
- function initFile (input) {
- const files = input.files;
- let html = '';
- if (fileArray.length > 5) {
- alert('파일은 5개까지 업로드 가능합니다.')
- } else {
- fileArray.push(files);
- }
- const ul = document.getElementById('lg_file_list');
- const textNode = document.createTextNode(files[0].name);
- const li = document.createElement('li');
- li.setAttribute('class', 'list-group-item')
- li.appendChild(textNode);
- ul.appendChild(li);
- }
|