Ask coding questions

← Back to all posts
help with login button
syflexer (480)

so on the login page of my website i cant get the login button to make the form i wrote in javascript to show up

Comments
hotnewtop
Coder100 (18187)

Form elements override js
So
Have to add preventDefault

button.addEventListener(function(e) {
  e.preventDefault();
});
syflexer (480)

@Coder100 i will try it that tomarow

Coder100 (18187)

You put it in the wrong place @syflexer

Coder100 (18187)

Put it outside of the function @syflexer

syflexer (480)

@Coder100 that still doesnt work for some reason i think i am just bad lol

51LV3RC0D3R (22)

Here is an example that worked for me.

.button {
  background-color: #4CAF50; /* Green */
  border: none;
  color: green;
  padding: 16px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  margin: 4px 2px;
  transition-duration: 0.4s;
  cursor: pointer;
  border-radius: 1000px;
  
}

.button1 {
  background-color: white; 
  color: black; 
  border: 2px solid #4CAF50;
}

.button1:hover {
  background-color: #4CAF50;
  color: white;

}
<style>
<body>
<a href="./login" class="button button1">Login</a>
</body>
syflexer (480)

@51LV3RC0D3R it needs to be through the java script on login.php and it has to have all the form stuff the standared button stuff wouldnt work properly for the purpose