<html>
<body>
<form>
<fieldset id="myFieldset" name="personalia">
Name: <input type="text" name="username"><br>
Email: <input type="text" name="usermail"><br>
</fieldset>
</form>
<p>Click the button to display the name of the fieldset.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myFieldset").name;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>