IgniteUI / ignite-ui

Ignite UI for jQuery by Infragistics
https://bit.ly/2kuu1fT
Other
477 stars 84 forks source link

igValidator cannot be applied to input type=radio with dot in 'name' attribute #2233

Open RivaIvanova opened 1 year ago

RivaIvanova commented 1 year ago

Description

Consider the following:

<div>
  <label>First name*</label>
  <input type="text" id="firstName" />
</div>
<div>
  <input id="radioyes" type="radio" name="radio.button" value="Yes" />
  <label for="radioyes">Yes</label>
</div>
<div>
  <input id="radiono" type="radio" name="radio.button" value="No" />
  <label for="radiono">No</label>
</div>
$("#validationForm").igValidator({
  onsubmit: true,
  successMessage: "Valid",
  fields: [
    {
      selector: "#firstName",
      required: true,
      onblur: true,
    },
    {
      selector: "#radiono",
      required: true,
      onchange: true,
    },
  ],
});

Setting the name attribute to radio.button or any other value that contains a dot throws an exception and other input fields are marked as valid even though they are set as required and no value is provided. Names like radio-button or radio_button are acceptable.

button

input

Note This could be due to the _findGroupTargets function which is used in _initializeField.

Steps to reproduce

  1. Open this demo
  2. Click on the different inputs -> The "Valid" success message is displayed although all fields are required.
  3. Open the Dev Console Tool -> An error is thrown.

Result

Setting the name attribute to a radio.button throws an error.

Expected result

No error should be thrown.