form
tag는 정보를 제출하기 위한 웹페이지에서의 입력 양식
을 의미한다. 예를 들어 로그인, 회원가입self-closing
form 양식 중에 제일 중요한 태그는 input 태그이다.
form
태그는 큰 틀의 양식이기 때문에 화면에 보이지 않는 추상적인 태그이므로 실제로 사용자 화면에 양식이 보이기 위해서는 input
태그를 사용해야한다.
<body>
<form>
<p>
<strong>가능한 파일 형식자</strong>
<input type="file" accept=".png"/> <!--png 타입의 파일을 업로드 할 수 있다.-->
<input type="file" accept=".image"/>
<input type="file" accept=".pdf"/>
<input type="file" accept=".png,.image,.pdf"/> <!--이 코드로 위의 세 줄을 한꺼번에 표현할 수 있다.-->
</p>
<p>
<strong>색 지정</strong>
<input type="color"> <!--색 고를 수 있다.-->
<input required placeholder="Name" type="text"> <!--name, placeholder는 input의 또다른 attribute-->
<input required placeholder="Last Name" type="text">
<input required placeholder="Username" minlength="10" type="text"> <!--user name,길이가 최소한 10이상은 되어야함-->
<input required placeholder="Password"type="password">
# required는 필수로 작성해야하는 칸을, placeholder는 사용자에게 무엇을 쓰기 위한 칸인지를 알려준다.
</p>
<p>
<strong>이름,성,유저네임,비밀번호</strong>
</p>
<p>
<strong>성별</strong>
<input type="radio" name="gender" value="M">남자
<input type="radio" name="gender" value="F">여자
</p>
<p>
<strong>응시분야</strong>
<input type="checkbox" name="part" value="English">영어
<input type="checkbox" name="part" value="Math">수학
</p>
<p>
<strong>제출 버튼</strong>
<input type="submit" /> <!--'제출'버튼-->
<input type="submit" disabled /> <!--disabled를 쓰면 '제출'버튼을 클릭할 수 없도록 비활성화 시킴-->
<input type="submit" value="Creat Account"/> <!--vaule라는 속성을 써서 적혀있는 'submit'이라는 글자를 'Creat Account'로 변경할 수 있다.-->
</p>
# '제출' 버튼을 누르면 사용자가 작성한 사용자 정보 양식을 백엔드 서버로 보내준다.
# input 태그의 required 속성은 (submit에 추가 불가능) validation(검증)을 할 수 있도록 해준다. 쉽게 말해, 필수란.
</form>
</body>
<input type="color"> # 버튼 색
<input placeholder="Name" type="text">
<input placeholder="Last Name" type="text">
<input placeholder="Username" type="text">
<input placeholder="Password" type="password">
<input required placeholder="Username" type="text">
# 필수란
<input required placeholder="Username" minlength="10" type="text">
<p>
<strong>성별</strong>
<input type="radio" name="gender" value="M">남자
<input type="radio" name="gender" value="F">여자
</p>
<p>
<strong>응시분야</strong>
<input type="checkbox" name="part" value="English">영어
<input type="checkbox" name="part" value="Math">수학
</p>
<p>
<strong>제출 버튼</strong>
<input type="submit" />
<input type="submit" disabled />
<input type="submit" value="Creat Account"/>
</p>