How to dynamically disable a form button using Javascript, HTML, and CSS

preview_player
Показать описание
#javascript #html #css #html5

Make button disable when inputbox is empty

Looking for source code check Commentbox

other HTML5 video

Рекомендации по теме
Комментарии
Автор

java.html



<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="java.css">
<title>Make no clickable button when inbox is empty</title>
</head>
<body>

<div class="container">

<h1>Signup Form</h1>

<form method="post">

<input type="text" id="name" placeholder="Enter Name"><br>

<input type="submit" value="Submit" id="submit" disabled>




</form>

</div>


<script src="./java.js"></script>

</body>
</html>




java.css




*{
padding: 0;
margin: 0;
box-sizing: border-box;
}
body{
background-color: #ffd662ff;
}
.container{
width: 400px;
height: 500px;
background-color: #00539cff;
border-radius: 25px;
position: absolute;
top: 20%;
left: 40%;
text-align: center;
}
.container input{
border-radius: 25px;
text-align: center;
margin-top: 100px;
padding: 20px;
}
#submit{
width: 160px;
height: 50px;
}
.container h1{
margin-top: 50px;
}




java.js



const username =
const submit =


username.addEventListener("keyup", (e)=>{

const value = e.currentTarget.value;

if (value == "") {

submit.disabled = true;

}else{

submit.disabled = false;

}

});

RealCodingHero