HTML code:
<form id="formular" method="post" action="input.php" enctype="multipart/form-data">
<div class="input check_boxes required wish_payment_type">
<div class="wish_payment_type">
<span class="checkbox payment-radio">
<label for="wish_payment_type_1">
<input class="check_boxes required" id="wish_payment_type_1" name="wish[payment_type][]" type="checkbox" value="ridicare produs"><font face ="Impact" size="+3">Vreau să ridic un produs</font><br /><br />
</label>
</span>
<span class="checkbox payment-radio">
<label for="wish_payment_type_2">
<input class="check_boxes required" id="wish_payment_type_2" name="wish[payment_type][]" type="checkbox" value="predare produs"><font face ="Impact" size="+3">Vreau să predau un produs</font><br /><br />
</label>
</span>
<span class="checkbox payment-radio">
<label for="wish_payment_type_3">
<input class="check_boxes required" id="wish_payment_type_3" name="wish[payment_type][]" type="checkbox" value="informatii"><font face ="Impact" size="+3">Vreau să adresez o întrebare</font><br /><br />
</label>
</span>
<span class="checkbox payment-radio">
<label for="wish_payment_type_4">
<input class="check_boxes required" id="wish_payment_type_4" name="wish[payment_type][]" type="checkbox" value="reclamatie"><font face ="Impact" size="+3">Vreau să fac o sesizare</font><br /><br />
</label>
</span>
<span class="checkbox payment-radio">
<label for="wish_payment_type_5">
<input class="check_boxes required" id="wish_payment_type_5" name="wish[payment_type][]" type="checkbox" value="factura storno"><font face ="Impact" size="+3">Vreau să ridic factura storno</font><br /><br /><br /><br />
</label>
<input required="required" type="text" class="inp" name="nume" size="30" placeholder="Introdu aici numele şi prenumele tău"><br /><br /><br /><br />
<input id='submit' type="submit" onClick="toUpper()" class="buttons" value="ÎNREGISTRARE"><br /><br />
</div>
</form>
脚本代码:
<script type="text/javascript">
var verifyPaymentType = function () {
var checkboxes = $('.wish_payment_type .checkbox');
var inputs = checkboxes.find('input');
var first = inputs.first()[0];
inputs.on('change', function () {
this.setCustomValidity('');
});
first.setCustomValidity(checkboxes.find('input:checked').length === 0 ? 'Selectați opțiunea dorită.' : '');
}
$('#submit').click(verifyPaymentType);
</script>
来自input.php
的变量代码:
$motiv = $_POST['wish'];
也许我很傻,看不到。它返回ARRAY文本,而不是复选框中的值。任何人都有关于设置正确$motiv = $_POST['wish'];
的明确观点吗?干杯:)