I am trying to print the value from the form when a user submits the function but a blank value is returned.
var name = null ;
this.validation = function()
this.name = document.getElementById("Username").value;
document.getElementById("demo").innerHTML = this.name;
And my HTML form as :
Please Enter Following Details
Why does the value not get into html
Your code simply works. But since the function executes on submitting the form, the username gets logged in the console fast before the page refreshed with submitted data. You can confirm this and test it by adding event.preventDefault(); to the function to prevent submitting the form so the page would stay visible with the console.
If that’s not what you’re looking for, let me know.