There is a group of type="radio" inputs with the same name , for example:

 <input type="radio" name="someName" value="someValue1" /> <input type="radio" name="someName" value="someValue2" /> <input type="radio" name="someName" value="someValue3" /> 

How to check whether at least one input from the group name="someName" selected on a clean Java name="someName" but in such a way that the condition is placed on one line along with some other condition (as far as I understand the cycle does not fit?). For example:

 if(someString.length > 0 && /* здесь условие для проверки инпутов name="someName" */) { 
  • one
    document.querySelector('input[name="someName"]:checked').value != null is suitable? - Alexey Shimansky

1 answer 1

Try this:

 if (someString.length > 0 && document.querySelector('input[name="someName"]:checked')) { // do smth }