Input Radio required Property - Set a radio button to be a required part of form submission: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Radio

Description

Input Radio required Property - Set a radio button to be a required part of form submission:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<form action="#">
  Radio Button: <input type="radio" id="myRadio" name="test">
  <input type="submit">
</form>/*from w  w  w .  j a  v a  2s .  c  o m*/

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
    document.getElementById("myRadio").required = true;
    document.getElementById("demo").innerHTML = "The required property was set.";
}
</script>

</body>
</html>

Related Tutorials