lundi 22 février 2016

JQuery if statement not detecting span checkbox properly

I have a span checkbox and I'd like to check to see if it's checked.

I believe it's not detecting the checkbox correctly for some reason.

My current code(abbreviated -- there's actually many error checks that are similar to the #cb_head line):

    function validate() {

    var errMessage = "";
    if (!$('#cb_head').is(":checked")) {
        errMessage += "Header\n";                
    }

    if (errMessage !== "") {
            errMessage += "Hasn\'t been verified, proceed with proof?";
            confirm(errMessage);
            return false;
        }
        else {
            return true;
        }

    }

The checkbox html:

<td class="dxflNestedControlCell_Office2010Black">
<span class="dxichCellSys dxeBase_DevEx dxeTAR" id="cb_head">
<span id="cb_head_S_D" class="dxICheckBox_DevEx dxichSys dxWeb_edtCheckBoxChecked_DevEx">
<input id="cb_head_S" name="ctl00$ctl00$ASPxSplitter1$Content$ContentSplitter$MainContent$ASPxCallbackPanel1$ASPxFormLayout3$cb_head" value="U" readonly="readonly" style="border-width:0;width:0;height:0;padding:0;margin:0;position:relative;background-color:transparent;display:block;" type="text">
</span></span>
</td>

So here's what I've tried to get it working but to no avail:

Finding the checkbox child elements: JQuery check if checkbox is NOT checked

I believe the error I'm having is somewhere in the HTML but I've tried the IDs:

cb_head_S_D
cb_head_S
cb_head

But still it doesn't seem to detect the right ID properly.

Happy to provide more info if needed.




Aucun commentaire:

Enregistrer un commentaire