웹프로그래밍/javascript

javascript - 빈칸체크하기

zelkova 2011. 3. 30. 17:43
http://www.phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=27154 에서 퍼왔습니다. 글쓰신분 감사합니다.

<form name=form1 action="javascript:frmchk()">
<input type=text size=3 >-<input type=text size=3><br>
<textarea rows=5></textarea>
<input type=submit value=전송>
</form>


<script language='javascript'>
function frmchk() {
        frm=document.form1
        num=frm.length-1
        for(i=0;i<=num;i++){
                if(frm.elements[i].value=="")
                {
                        alert("값을 넣어 주세요");
                        frm.elements[i].focus();
                return ;
                }
        }
}
</script>

반응형