다음은 구문입니다-
<select required>
이제
예시
<!DOCTYPE html> <html> <body> <h1>Candidate Profile</h1> <p>Following are the details to be submitted by the candidate:</p> <h2>Educational Qualification</h2> <form action=""> <section> <h3>Graduation</h3> <select required> <option value="">None</option> <option value="bca">BCA</option> <option value="bcom">B.COM</option> <option value="btech">B.TECH</option> </select> </section> <section> <h3>Postgraduation</h3> <select> <option value="mca">MCA</option> <option value="mcom">M.COM</option> <option value="mtech">M.TECH</option> <option value="msc">M.Sc</option> </select> </section><br> <input type="submit" value="Next"> </form> </body> </html>
그러면 다음과 같은 출력이 생성됩니다. 필요에 따라 설정된 드롭다운 목록에서 항목을 선택하지 않았으므로 다음 경고가 표시됩니다-
위의 예에서
<section> <h3>Graduation</h3> <select required> <option value="">None</option> <option value="bca">BCA</option> <option value="bcom">B.COM</option> <option value="btech">B.TECH</option> </select> </section> <section> <h3>Postgraduation</h3> <select> <option value="mca">MCA</option> <option value="mcom">M.COM</option> <option value="mtech">M.TECH</option> <option value="msc">M.Sc</option> </select> </section>
필수 속성을 사용하여 사용자가 필수 항목 중 하나를 채우도록 설정했습니다. 그렇지 않으면 양식이 제출되지 않습니다-
<section> <h3>Graduation</h3> <select required> <option value="">None</option> <option value="bca">BCA</option> <option value="bcom">B.COM</option> <option value="btech">B.TECH</option> </select> </section>