- Thu Dec 28, 2017 4:02 pm
#812662
Is there a way that I can have forms colored that are missing information? For example, having the fields with values of nothing highlighted as blue?
//set the IDs of the fields to be checked if empty:
var aFieldsToCheck = ['name', 'address', 'clientType', 'taxIncluded',
'workStartDate', 'userResponsible'];
function checkIfEmpty(fieldId, val) {
//if in array of fields that shouldn't be empty:
if ($.inArray(fieldId, aFieldsToCheck) != -1) {
var fieldType = $("#"+fieldId).getInfo()['type']
if (fieldType == 'checkbox') {
if (val == '0' || val == '"0"')
$("#"+fieldId).getControl().closest('div').css('backgroundColor', 'blue');
else
$("#"+fieldId).getControl().closest('div').css('backgroundColor', ''); //default
}
else { //any other type of field but checkbox:
if (val == '')
$("#"+fieldId).getControl().css('borderColor', 'blue');
else
$("#"+fieldId).getControl().css('borderColor', ''); //set back to default color
}
}
}
function checkAllFields() {
for (idx in aFieldsToCheck) {
var fieldId = aFieldsToCheck[idx];
var val = $("#"+fieldId).getValue();
checkIfEmpty(fieldId, val);
}
}
checkAllFields(); //call when the DynaForm loads
var formId = $("form").prop("id");
$("#" + formId).setOnchange(function(fieldId, newVal, oldVal) {
checkIfEmpty(fieldId, newVal);
});
In the rapidly evolving world of online sports be[…]
STEPN integrates social networking and games that […]
Cenforce 150 is a medication used to cope with a c[…]