I've created a form that includes multiple checkboxes with corresponding input fields.
<div class="group-wrap input-element" id="gr_">
<div class="label-bar">
<label>
<div class="custom-control form-check">
<input class="form-check-input" value="1" type="checkbox" id="Gleitzeitmaxstundenenable" name="Gleitzeitmaxstundenenable" onmouseup="{setActFeld(this.id);}" onfocus="{ setActFeld(this.id);}" onclick="{setConfirmedChange(this.id, "false&") ; initCheckBox(this.id);transaktionObj.inputEnable(this.checked,"Gleitzeitmaxstunden&");}">
<label class="form-check-label" for="Gleitzeitmaxstundenenable">Gleitzeit max.</label>
</div>
</label>
</div>
<input placeholder="Gleitzeitmaxstunden" name="Gleitzeitmaxstunden" class="form-control text-truncate input-sm zeit-raum withSign numValPicker timecount disabled" data-syntax="-NNN:NN" value="" data-prefix="true" id="Gleitzeitmaxstunden" maxlength="7" type="text" onmousedown="{ if(checkPickerVoll(this.id)){ return false;}else{return (updateZeitMitSign(this,4, false));}}" onkeyup="{ if(checkPicker(this.id)){ return false;} else{return (updateZeitMitSign(this,4, true));}}" onfocus="{ setActFeld(this.id);}" onkeydown="{ if(checkPickerVoll(this.id)){ return false;}else{return (updateZeitMitSign(this,4, false));}}"...
Whenever a checkbox is ticked and the user inputs a value in the corresponding field, the TS
method should confirm as true
.
let fehler = false;
$JQ("input.form-check-input").each(function(ind: number, checkBox: Element){
const checkbox = $JQ(checkBox);
const inputId = checkbox.attr("id").replace("enable", "");
if($JQ(`#${inputId}`).val() !== ""){
fehler = true;
}
});
return fehler;
However, the condition $JQ(
#${inputId}).val() !== ""
always results in true
. I would appreciate any assistance provided.