我在我的Wordpress网站上使用了四个单选按钮。
如果用户选择一个单选按钮并单击“提交”按钮,则除了管理员以外,该用户将来将无法更改/选择其他选项。
我在网站上使用了很多单选按钮。所以我想将此应用到
.option-label .iradio_minimal
$('input:checkbox').click(function() {
var $inputs = $('input:checkbox');
if ($(this).is(':checked')) {
$inputs.not(this).prop('disabled', true); // <-- disable all but checked one
} else {
$inputs.prop('disabled', false); // <--
}
}
)
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<label for="option_76" class="option-label">
<span class="iradio_minimal">
<input type="radio" name="field_54" id="option_76" value="testing 1" style="position: absolute; opacity: 0;">
<ins class="iCheck-helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; background: rgb(255, 255, 255); border: 0px; opacity: 0; cursor: pointer;"></ins>
</span>testing 1
</label>
<label for="option_77" class="option-label">
<span class="iradio_minimal">
<input type="radio" name="field_54" id="option_77" value="testing 2" style="position: absolute; opacity: 0;">
<ins class="iCheck-helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; background: rgb(255, 255, 255); border: 0px; opacity: 0; cursor: pointer;"></ins>
</span>testing 2
</label>
<label for="option_78" class="option-label">
<span class="iradio_minimal">
<input type="radio" name="field_54" id="option_78" value="testing 3" style="position: absolute; opacity: 0;">
<ins class="iCheck-helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; background: rgb(255, 255, 255); border: 0px; opacity: 0; cursor: pointer;"></ins>
</span>testing 3
</label>
<label for="option_79" class="option-label">
<span class="iradio_minimal">
<input type="radio" name="field_54" id="option_79" value="testing 4" style="position: absolute; opacity: 0;">
<ins class="iCheck-helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; background: rgb(255, 255, 255); border: 0px; opacity: 0; cursor: pointer;"></ins>
</span>testing 4
</label>
答案 0 :(得分:0)
您需要禁用提交事件中的所有输入,而不要禁用输入单击事件:
Route::get('/delete', function(){
$user = User::findOrFail(1);
$user->address()->delete();
});
$('form').on('submit',function(){
var $inputs = $('input:checkbox');
if($('input:checkbox:checked').length) {
$inputs.prop('disabled',true);//disable all if at least one is checked
}
})