다시 문의드려요~ 입력내용의 유효성을 검사
본문
입력내용의 유효성을 검사해서 입력하지 않은부분을 체크하여 리턴하려합니다.
해당파일은 adm/newwinform.php입니다.
-----------------------------------------------------------------
<tr>
<th scope="row"><label for="nw_content">내용</label></th>
<td>
<?php echo editor_html('nw_content', get_text($nw['nw_content'], 0)); ?>
</td>
</tr>
-----------------------------------------------------------------
form name은 frmnewwin입니다.
<script type="text/javascript">
if (document.frmnewwin.nw_content.value=='') {
alert("내용을 입력해주세요.");
return false;
}
</script>
이렇게 하면 내용을 입력하든 안하든 무조건 체크됩니다.
내용을 입력하지 않았을때만 체크되고 내용입력박스로 포커스가 이동되게 하려합니다.
꼭 답변 부탁드립니다.
답변 1
if (document.frmnewwin.nw_content.value=='') {
위 부분은 웹표준 방식은은 아닌듯 하구요.
아래와 같이 한번 고쳐 해보세요.
if (document.getElementById("nw_content").value ==""){
답변을 작성하시기 전에 로그인 해주세요.