Edit This Code:
<!DOCTYPE html>
<html>
<body>

<input type="number" id="myNumber" name="quantity">

<p>Click the buttons to display and/or change the value of the name attribute of the number field.</p>

<button onclick="display()">Display name</button>
<button onclick="change()">Change name</button>

<p><strong>Note:</strong> input elements with type="number" are not supported in IE 9 and earlier versions.</p>

<script>
function display() {
    var x = document.getElementById("myNumber").name;
    alert("The name of the number field is: " + x);
}

function change() {
    var x = document.getElementById("myNumber").name = "newNumberName";
    alert ("The name was changed to: " + x);
}
</script>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy