<input type ="text" id = "text">

<input type = "submit" value = "버튼" onclick = "ckd()")


<script type="text/javascript">

window.onload = function() {

document.getElementById('text').focus();

}

function ckd() {

if (document.getElementById('text').value == "") {

alert("비었어요");

}

}


브라우저가 새로고침을 하면 text라는 id를 가진 태그에 포커스를 해준다.


text라는 id를 가진 태그의 값을 버튼 클릭 시에 체크하여 비어있다는 것을 체크해준다.

블로그 이미지

왕왕왕왕

,