在我的 html 页面中,我有一个表单,其中包含一系列标记为“必填”的字段。如果有人忘记选择选项并单击提交,他们会被告知必须填写表格。但是,当我添加 jquery hide() 和 show() 时,所需的属性将被忽略,并且单击按钮会自动显示下一个 div,无论表单是否已填写。任何建议将不胜感激。
html/jquery:
<script>
$(document).ready(function(){
$("#ChatFormat").hide();
//$("#QuestSubmit").bind(("click",function(){
$("#QuestSubmit").click(function(){
$("#ChatFormat").show();
$("#QuestFormat").hide();
});
});
</script>
</head>
<body>
<div class="wrapper" id="QuestFormat">
<div id="menu">
<div style="clear:both"></div>
</div>
<div class="container" id="chatbox">
<form id = "IntroQuest">
<h4>Please take a moment to answer a few quick questions. Thank you.</h4>
<h4>What is your gender?
<select id = "Gender" required>
<option value selected>-Select-</option>
<option value = "Male">Male</option>
<option value = "Female">Female</option>
</select>
</h4>
<h4>What is your ethnicity?
<select id = "Ethnicity" required>
<option value selected>-Select-</option>
<option value = "Caucasian">Caucasian</option>
<option value = "Hispanic/Latino">Hispanic / Latino</option>
<option value = "Asian">Asian</option>
<option value = "MiddleEastern">Middle Eastern</option>
<option value = "PacificIslander">Pacific Islander</option>
<option value = "NativeAmerican">Native American</option>
<option value = "Other">Other</option>
</select>
<input class = "submitbutton" id = "QuestSubmit" type = "submit" value = "Begin Chat">
</form>
</div>
</div>
<div class="wrapper" id="ChatFormat">
<div id="menu">
<div style="clear:both"></div>
</div>
<div class="container" id ="chatbox"></div>
<form name="message" action="">
<input id="input" class="bottom" name="usermsg" type="text" id="usermsg" size="63" />
<input class="submitbutton" name="submitmsg" type="submit" id="submitmsg" value="Send" />
</form>
</div>
</body>