관리 메뉴

moozi

join2.html 본문

TIS_2016/HTML5_3기

join2.html

moozi 2016. 7. 27. 17:43

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <title>회원가입</title>

    <style>

        input:focus{background-color: lightblue;}

    </style>

    <script>

        function check(){

            var id=document.form1.id.value;

            if(id==""){

                alert("id를 입력하세요");

                document.form1.id.focus();//포커스

                return false;// 함수종료.false값 리턴.함수의 리턴값은 함수호출한 자리로.

            }

            var pw=document.form1.password.value;

            if(pw==""){

                alert("pw를 입력하세요");

                document.form1.password.focus();

                return false;

            }

            var name=document.form1.name.value;

            if(name.length==0){

                alert("이름을 입력하세요");

                document.form1.name.focus();

                return false;

            }

            var email=document.form1.email.value;

            if(email.length==0){

                alert("이메일을 입력하세요");

                document.form1.email.focus();

                return false;

            }

            

            var birth=document.form1.birth.value;//생년월일추출

            if(isNaN(birth)){

                alert("숫자형식으로 입력하세요!\n예)20020101");

                document.form1.birth.focus();

                return false;

            }

            

           

        }

    </script>

</head>

<body>

    <h1>회원가입</h1>

    <form name="form1" action="join.php" method="post" onSubmit="return check();">

    ID <input type="text" name="id"><br/>

    PW <input type="password" name="password"><br/>

    이름 <input type="text" name="name"><br/>

    생년월일 <input type="text" name="birth"><br/>

    성별 <input type="radio" name="gender" value="남">남

        <input type="radio" name="gender" value="여">여<br/>

    이메일 <input type="email" name="email"><br/>

    주소 <input type="text" name="address"><br/>

    취미 <input type="checkbox" name="hobby1" value="h1">운동

    <input type="checkbox" name="hobby2" value="h2">독서

    <input type="checkbox" name="hobby3" value="h3">게임

    <input type="checkbox" name="hobby4" value="h4">영화감상<br/>

    직업 <select name="job">

            <option value="j1">공무원</option>

            <option value="j2">직장인</option>

            <option value="j3">학생</option>

            <option value="j4">기타</option>

        </select><br/>

    인사말 <br/>

    <textarea name="comment" cols="50" rows="5"></textarea><br/>

    사진 <input type="file" name="picture"> <br/>

    <input type="submit" value="등록">

    <input type="reset" value="취소">    

    </form>

</body>

</html>

Comments