아래의 소스에서 사진 등록을 필수로 하려면 어떻게 해야하나요.

아래의 소스에서 사진 등록을 필수로 하려면 어떻게 해야하나요.

QA

아래의 소스에서 사진 등록을 필수로 하려면 어떻게 해야하나요.

본문

 아래의 소스에서 사진 등록을 필수로 하려면 어떻게 해야하나요.


             <script language="JavaScript">
        var flen = 0;
        function add_file(delete_code)
        {
            var upload_count = <?=(int)$board[bo_upload_count]?>;
            if (upload_count && flen >= upload_count)
            {
                alert("이 게시판은 "+upload_count+"개 까지만 파일 업로드가 가능합니다.");
                return;
            }

            var objTbl;
            var objRow;
            var objCell;
            if (document.getElementById)
                objTbl = document.getElementById("variableFiles");
            else
                objTbl = document.all["variableFiles"];

            objRow = objTbl.insertRow(objTbl.rows.length);
            objCell = objRow.insertCell(0);


            objCell.innerHTML = "<input type='file' class=tx size=12 name='bf_file[]' title='파일 용량 <?=$upload_max_filesize?> 이하만 업로드 가능' style='color:<?=$board[bo_color_6]?>;background-color:<?=$board[bo_color_5]?>;border-color:<?=$board[bo_color_4]?>;border-width:1px;'><br>";



            if (delete_code)
                objCell.innerHTML += delete_code;
            else
            {

                <? if ($is_file_content) { ?>


                objCell.innerHTML += "<br><input type='text' size=12 class=tx name='bf_content[]' title='업로드 이미지 파일에 해당 되는 내용을 입력하세요.' style='width:100%; color:<?=$board[bo_color_6]?>;background-color:<?=$board[bo_color_5]?>;border-color:<?=$board[bo_color_4]?>;border-width:1px;'>";


                <? } ?>
                ;

            }

            flen++;
        }

        <?=$file_script; //수정시에 필요한 스크립트?>

        function del_file()
        {
            // file_length 이하로는 필드가 삭제되지 않아야 합니다.
            var file_length = <?=(int)$file_length?>;
            var objTbl = document.getElementById("variableFiles");
            if (objTbl.rows.length - 1 > file_length)
            {
                objTbl.deleteRow(objTbl.rows.length - 1);
                flen--;
            }
        }
        </script>

이 질문에 댓글 쓰기 :

답변 4

그누보드 기본체크소스를 활용하면
 
objCell.innerHTML = "<input type='file' class=tx size=12 name='bf_file[]'  <==이부분에
 
 
objCell.innerHTML = "<input type='file' class=tx size=12 name='bf_file[]' required 로 수정해보세요
 
기본체크스크립트가 required 를 인식해서  체크합니다
선택이란님, 답변 대단히 감사합니다.
objCell.innerHTML = "<input type='file' class=tx size=12 name='bf_file[]' required 로 수정했습니다.

수정후 사진을 업로드하고 확인을 누르면, 다시 사진을 넣으라고 메시지가 나옵니다. 
원본파일은 아래와 같습니다. 

              <script language="JavaScript">
        var flen = 0;
        function add_file(delete_code)
        {
            var upload_count = <?=(int)$board[bo_upload_count]?>;
            if (upload_count && flen >= upload_count)
            {
                alert("이 게시판은 "+upload_count+"개 까지만 파일 업로드가 가능합니다.");
                return;
            }

            var objTbl;
            var objRow;
            var objCell;
            if (document.getElementById)
                objTbl = document.getElementById("variableFiles");
            else
                objTbl = document.all["variableFiles"];

            objRow = objTbl.insertRow(objTbl.rows.length);
            objCell = objRow.insertCell(0);

            objCell.innerHTML = "<input type='file' class=tx size=12 name='bf_file[]' required title='파일 용량 <?=$upload_max_filesize?> 이하만 업로드 가능' style='color:<?=$board[bo_color_6]?>;background-color:<?=$board[bo_color_5]?>;border-color:<?=$board[bo_color_4]?>;border-width:1px;'><br>";

            if (delete_code)
                objCell.innerHTML += delete_code;
            else
            {

                <? if ($is_file_content) { ?>


                objCell.innerHTML += "<br><input type='text' size=12 class=tx name='bf_content[]' required title='업로드 이미지 파일에 해당 되는 내용을 입력하세요.' style='width:100%; color:<?=$board[bo_color_6]?>;background-color:<?=$board[bo_color_5]?>;border-color:<?=$board[bo_color_4]?>;border-width:1px;'>";


                <? } ?>
                ;

            }

            flen++;
        }

        <?=$file_script; //수정시에 필요한 스크립트?>

        function del_file()
        {
            // file_length 이하로는 필드가 삭제되지 않아야 합니다.
            var file_length = <?=(int)$file_length?>;
            var objTbl = document.getElementById("variableFiles");
            if (objTbl.rows.length - 1 > file_length)
            {
                objTbl.deleteRow(objTbl.rows.length - 1);
                flen--;
            }
        }
        </script>

답변을 작성하시기 전에 로그인 해주세요.
전체 123,805 | RSS
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT