Shopsystem ShopPilot

ShopPilot => Visual Forms => Thema gestartet von: dobra am Dezember 27, 2017, 21:54:54

Titel: Pflichfelder mit Bedingung
Beitrag von: dobra am Dezember 27, 2017, 21:54:54
Aufgabe:
die Angabe einer Telefonnummer soll im Kontaktformular nur dann ein Pflichtfeld sein, wenn telefonische Antwort gewünscht wird.

Lösung:
<form action="__UDC__#kontakt" method="post" name="Feedback" id="Feedback">
...
<div class="form-group col-md-12" style="margin-bottom: 0;">
Teilen Sie uns mit, wie wir Ihnen antworten sollen:<br>
<span style="padding-left: 20px;"><input type="radio" checked name="Kontaktart" value="email"> per E-Mail </span>
<span style="padding-left: 10px;"><input type="radio" name="Kontaktart" value="telefonisch"> telefonisch </span>
</div>
...
</form>

<script>
$(document).ready(function(){
$(':radio[name=Kontaktart]').click(function(){    
if($(this).val() == 'telefonisch'){
$("#tel").prop('required',true);
} else {
$("#tel").prop('required',false);
}
});
});             
</script>

Voraussetzung: