JSFiddle - React, Tailwind, and code Playground
by dixalex
JavaScript
function ProcessSubmit() {
var message = "Please enter the name of one brand or select 'No other brands'.";
var isValid = $("input:checkbox:checked").length;
var num = $("input:text").filter(function(index, element) {
return $(element).val().length !== 0;
}).length;
if ((isValid === 0) && (num === 0)) {
//alert(message);
$('.ncp_dialog').dialog('open');
return false;
}
return true;
}
function LoadPage() {
$('.ncp_dialog').dialog({
autoOpen: false,
modal: true,
title: 'Error',
appendTo: 'body',
buttons: [{
text: 'Close',
icon: 'ui-icon-closethick',
click: function() {
$(this).dialog('close');
}
}]
});
var input_fields = $(".question.fillin input:text");
var exclusive_checkbox = $(".question.choosemany input:checkbox");
$(exclusive_checkbox).on('change', function(exclusive_event) {
if ($(exclusive_event.target).is(':checked')) {
$(input_fields).each(function(index, input_field) {
$(input_field).val('').prop('readonly', true).addClass('ncp_disabled');
});
} else {
$(input_fields).each(function(index, input_field) {
$(input_field).prop('readonly', false).removeClass('ncp_disabled');
});
}
});
}
function prepopulate_format() {
var input_fields = $(".question.fillin input:text");
var exclusive_checkbox = $(".question.choosemany input:checkbox");
$(exclusive_checkbox).each(function(index, element) {
if ($(element).is(':checked')) {
$(input_fields).each(function(index, input_field) {
$(input_field).val('').prop('readonly', true).addClass('ncp_disabled');
});
} else {
$(input_fields).each(function(index, input_field) {
$(input_field).prop('readonly', false).removeClass('ncp_disabled');
});
}
});
}