본문 바로가기

2023.11.21-2024.05.31

240102 HTML write.jsp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>글쓰기</title>
<link rel="stylesheet" type="text/css" href="./css/write.css">
<script type="text/javascript">
    function check() {
        //alert('!');
        //var title = document.getElementsByName("title");
        //alert(title[0].value);//직접적으로 뽑을 수 없어서 0번지 어쩌구 적는다.
        var title = document.getElementById("title");
        //alert(title.value);
        if(title.value.length < 5){
            alert("제목은 5글자 이상이어야 합니다.");
            title.focus();//focus : 커서가 깜박깜박하는것
            return false;
        }
        var content = document.getElementsByClassName("content");
        //alert(content[0].value.length);
        if(content[0].value.length<3){
            alert("내용은 3글자 이상으로 적어주세요.");
        content[0].focus();
        return false;
        }
                
    }
</script>
</head>
<body>
    <h1>글 쓰기</h1>
    <!-- form 글 제목, 글 내용 -->
    <form action="./write" method="post">
        <input type="text" name="title" id="title">
        <textarea name="content"class="content"></textarea>
        <button type="submit" onclick="return check()">글쓰기</button>
    </form>
 
</body>
</html>
cs

'2023.11.21-2024.05.31' 카테고리의 다른 글

240102 HTML write.js  (0) 2024.01.03
240102 HTML writeAction.jsp  (0) 2024.01.03
240102 HTML update.jsp  (0) 2024.01.03
240102 HTML detail.jsp  (1) 2024.01.03
240102 HTML delete.jsp  (1) 2024.01.03