I know there are many questions about this topic but none similar to mine. so I have this new gaming website that I'm creating and I want to call for two functions that are totally different. one function that calls for the user to validate the form and the other function should display a welcome message right after validating the form.
I've tried many ways and I googled but none worked. Moreover the code isn't running although I've checked and everything is fine but still not running.
function validateFormSubmission() { let firstName = document.getElementById('firstName').value; let lastName = document.getElementById('lastName').value; if (firstName == null || firstName == "") { alert("First Name shouldn't be empty"); return false; } else if (lastName == null || lastName == "") { alert("Last Name shouldn't be empty"); return false; } else { return true; } } function showWelcomeMessage() { let firstName = document.getElementById('firstName').value; let lastName = document.getElementById('lastName').value; document.getElementById('outputDiv').innerHTML = 'Hey Gamer' + firstName + lastName + ', Welcome ' + '!'; } <body> <form onsubmit="return validateFormSubmission()"> <table> <tr> <td>Your first name-</td> <td><input type="text" name="firstName"></td> </tr> <tr> <td>Your last name-</td> <td><input type="text" name="lastName"></td> </tr> </table> </form> <form onclick="showWelcomeMessage()"></form> <input type="submit" value="Let's play" /> <hr> <div id="outputDiv"> </div> </body> </html>