To set HTML5 required attribute in JavaScript, we set the required property.
For instance, we write
document.getElementById("edName").required = true;
to select the input with getElementById.
And then we set its required property to true to make it a required input.