<input type="text" class="form-control" id="username" name="username" placeholder="Username" required="" autofocus="" />
<input type="password" class="form-control" id="password" name="pwd" placeholder="Password" required="" autofocus="" />
<input class="btn btn-lg btn-primary btn-block button marginT20" name="login" value="Login" type="Submit" onclick="login(document.getElementById('username').value,document.getElementById('password').value)" >
<script>
functionlogin(username, password){
$.ajax({
method: "POST",
url: "/login",
data: {
username: username,
pwd: password
}
}).done(function(msg1){
if(msg1=='success'){
window.location='/home';
}else{
varusername='username';varpassword='password';eraseCookie(username,
password);toastr.warning(msg1);
}
});
}
</script>
My code is working when someone presses the login button, but I want the username and password filled in if the user presses enter. Then the form is submitted with the existing ajax code.