Online jQuery Editor

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <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> <body> <form> Gender: <label><input type="radio" name="gen" value="male" />Male</label> <label><input type="radio" name="gen" value="female" />Female</label> <br /> isStudent: <label><input type="radio" name="student" value="yes" />yes<label> <label><input type="radio" name="student" value="no" />No</label> <br /> <input type="submit" /> </form> </body> <script> var nameValues = 'gen;student'.split(';'); $(function () { $("form").on("submit", function (ev) { if (nameValues.filter(val => $(`input[name=${val}]:checked`).length === 0).length > 0) { console.log("Radio Button is not checked"); ev.preventDefault(); } }) }) </script> </html>