I am currently working on creating a login feature using a bootstrap modal, but unfortunately, I am facing some issues with it. If anyone is willing to offer their assistance, I would greatly appreciate it.
My knowledge of JavaScript and Bootstrap is limited.
function login(){
var username=document.getElementsByName("username").value;
var password=document.getElementsByName("password").value;
if(username.value == null && password.value == null){
$('.alert').show();
}
else{
document.getElementById("wrongpassword").innerHTML="Thank u very much";
}
}
.alert{
display:none;
}
<div class="modal fade" id="modal1" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3 class="modal-title text-center" style="color:#333366;"><strong>LOGIN TO FOOD SAVIOR</strong></h3>
</div>
<div class="modal-body">
<div class="form-group">
<input type="text" placeholder="Username" name="username" class="form-control" style="height:40px;" required>
</div>
<div class="form-group">
<input type="password" placeholder="Password" name="password" class="form-control" style="height:40px;" required>
</div>
<div class="text-center">
<input type="submit" value="LOGIN" name="login_btn" id="login_btn" onclick="login()" class="btn btn-primary" style="background-color:#333366;height:40px;color:#ffffff">
</div>
<div class="alert alert-danger alert-dismissable fade in">
<button type="button" class="close" data-hide="alert">×</button>
<p> You Entered Wrong Detail. Enter Again
</p>
</div>
<p id="wrongpassword"></p>
<h4 class="text-center"><a href="#">Forget Password</a></h4>
</div>
<div class="modal-footer">
<h4 class="text-center">Don't have Account yet? Let's <a href="#modal2" data-toggle="modal">Sign up</a> its fun and easy!</h4>
<div class="text-center"><button type="button" class="btn btn-success" data-dismiss="modal"><p>Close</p></button>
</div>
</div>
</div>
</div>
</div>
<a href="#modal1" data-toggle="modal">
<h5>Login</h5></a>
strong text