I want to create a simple HTML document that contains label, textbox and button. When the user enters name and presses Go Navigate to another page that says Welcome {User Name} IF the name is empty display an alert that says “please enter your name”.
I can't move to the second page with the name user entered.
file1 HTML
     <h2> Enter your name.</h2><br>
  <input id="name">
    <button onclick="action()">GO</button>
     <script src="action.js">
       </scipt>
file js
    function action() {
          var PersonName = document.getElementById('name').value;
          if (PersonName== "") {
        alert("please enter your name!");
       return false;
                }
    else{
            document.location.href = "index2.html";
      }}
 
     
    