我在DIV中使用display:none的字段提交表单后遇到验证问题。 我正在使用jquery显示/隐藏DIV的单选按钮。 并且所有字段都应该是必填字段..
当DIV中的字段与联系人form7中的display:none时,是否可以忽略验证。
请帮我找一个解决方案
参考代码。
<div class="f7-row">
<div class="f7-label">Sorgeberechtigte*</div>
<div class="f7-input">[radio Sorgeberechtigte "Mutter" "Vater" "beide" "andere Person"] </div>
</div>
<div id="mutter" style='display:none'>
<h1>MUTTER</h1>
<div class="f7-row"><div class="f7-label">Vorname*</div><div class="f7-input">[text* MUTTER_Vorname]</div></div>
<div class="f7-row"><div class="f7-label">Nachname*</div><div class="f7-input">[text* MUTTER_Nachname]</div></div>
<div class="f7-row"><div class="f7-label">Straße*</div><div class="f7-input">[text* MUTTER_Strae]</div></div>
<div class="f7-row"><div class="f7-label">PLZ/Ort*</div><div class="f7-input">[text* MUTTER_PLZ]</div></div>
<div class="f7-row"><div class="f7-label">Telefonnummer*</div><div class="f7-input">[tel* MUTTER_Telefonnummer]</div></div>
<div class="f7-row"><div class="f7-label">berufstätig ab Aufnahme- bzw. Betreuungszeitpunkt des Kindes?*</div><div class="f7-input">[radio MUTTER_Betreuungszeitpunkt "Ja" "Nein"]</div></div>
</div>
<div id="vater" style='display:none'>
<h1>VATER</h1>
<div class="f7-row"><div class="f7-label">Vorname*</div><div class="f7-input">[text* VATER_Vorname]</div></div>
<div class="f7-row"><div class="f7-label">Nachname*</div><div class="f7-input">[text* VATER_Nachname]</div></div>
<div class="f7-row"><div class="f7-label">Straße*</div><div class="f7-input">[text* VATER_Strae]</div></div>
<div class="f7-row"><div class="f7-label">PLZ/Ort*</div><div class="f7-input">[text* VATER_PLZ]</div></div>
<div class="f7-row"><div class="f7-label">Telefonnummer*</div><div class="f7-input">[tel* VATER_Telefonnummer]</div></div>
<div class="f7-row"><div class="f7-label">berufstätig ab Aufnahme- bzw. Betreuungszeitpunkt des Kindes?*</div><div class="f7-input">[radio VATER_Betreuungszeitpunkt "Ja" "Nein"]</div></div>
</div>
<div id="anderer" style='display:none'>
<h1>anderer Personensorgeberechtigter</h1>
<div class="f7-row"><div class="f7-label">Vorname*</div><div class="f7-input">[text* anderer_Vorname]</div></div>
<div class="f7-row"><div class="f7-label">Nachname*</div><div class="f7-input">[text* anderer_Nachname]</div></div>
<div class="f7-row"><div class="f7-label">Straße*</div><div class="f7-input">[text* anderer_Strae]</div></div>
<div class="f7-row"><div class="f7-label">PLZ/Ort*</div><div class="f7-input">[text* anderer_PLZ]</div></div>
<div class="f7-row"><div class="f7-label">Telefonnummer*</div><div class="f7-input">[tel* anderer_Telefonnummer]</div></div>
<div class="f7-row"><div class="f7-label">berufstätig ab Aufnahme- bzw. Betreuungszeitpunkt des Kindes?*</div><div class="f7-input">[radio anderer_Betreuungszeitpunkt "Ja" "Nein"]</div></div>
</div>
Js代码供参考
$(document).ready(function() {
$('.Sorgeberechtigte input[type="radio"]').click(function() {
if($(this).attr('value') == 'Mutter') {
$('#mutter').show(500);
}
else {
$('#mutter').hide(500);
}});
$('.Sorgeberechtigte input[type="radio"]').click(function() {
if($(this).attr('value') == 'Vater') {
$('#vater').show(500);
}
else {
$('#vater').hide(500);
}});