KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am looking to make a simple form validation error message that displays under the username field. I cannot seem to figure it out. <form name ="myform" onsubmit="validation()"> Username: <input type ="text" name="username" /><br /> <input type ="submit" value="submit" /> <div id ="errors"> </div> </form> Here is my validation script: function validation(){ if(document.myform.username.value == ""){ //checking if the form is empty document.getElementById('errors').innerHTML="*Please enter a username*"; //displaying a message if the form is empty }
Tags (comma-separated)
Save Edits
Cancel