FLICKER FLICKER - 1 year ago 518
HTML Question

Can't create checkboxradio on element.nodeName=input and element.type=text

I have following html and when I preview the page, I get following error:

Can't create checkboxradio on element.nodeName=input and

<head runat="server">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" />
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
$(function () {
<form action="#">
<label for="cbxForRent">For Rent</label>
<input type="checkbox" id="cbxForRent" />
<input type="text" id="txtZipCode" />

If I remove

<input type="text" id="txtZipCode" />

it will work properly. I think jquery tries to do something with the

what is the best way to resolve this issue?

Answer Source

The jQuery UI checkboxradio plugin works on checkboxes with a label only, not on text inputs, and $('input') targets both tags, make sure you target the checkbox only, and jQuery UI will no longer throw the error when it tries to convert a text input into a radiobutton

$(function () {

You could also target all checkboxes on the page with


or give them a common class to target them etc.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download