Skip to content
Advertisement

JavaScript validation for username and password not working in html file

I am creating a program called “Login & Sign-up Form”. The program involve Java Servlet, HTML, CSS which are working fine and JavaScript which i am having problem. I am using JavaScript to validate the username, password and email before submitting them. However, when i click on the “Submit” button, it directly goes to page showing “log @ register success” without checking the three fields. I noticed that the email filed is only checked as it will be done by the browser automatically. Please help me to solve this issue as i do not know what is the problem. Thank you very much. Below is the html code followed by css code. I also add the java servlet code too add below. Your help is much appreciated.

INDEX.HTML

JavaScript

***LOGINFAIL.HTML

JavaScript

REGISTERSUCCESS.HTML

JavaScript

css code

JavaScript

RegSucess.java

JavaScript

LogSucess.java

JavaScript

Advertisement

Answer

In addition to Jon P’s answer adding “required” in your html like:

JavaScript

will make it a required field for submission, this wont fix the validation problem but right now you would not need to give any response to continue

Advertisement