enter key simulated submit form

This commit is contained in:
2019-08-26 11:58:11 +02:00
parent e503586e61
commit 8f2e76cbfa
4 changed files with 57 additions and 43 deletions

View File

@@ -8,31 +8,21 @@
<br />
<div class="col-md-offset-4 col-md-4 well">
<form id="login-form" role="form" action="${url}" method="post"
data-fv-framework="bootstrap"
data-fv-icon-valid="glyphicon glyphicon-ok"
data-fv-icon-invalid="glyphicon glyphicon-remove"
data-fv-icon-validating="glyphicon glyphicon-refresh">
<form id="login-form" role="form" action="${url}" method="post" >
<h3>Se connecter</h3>
<input type="hidden" name="came_from" value="${came_from}"/>
<div class="form-group">
<input class="form-control" type="text" name="login" value="${login}"
placeholder="Identifiant"
data-fv-notempty="true"
data-fv-notempty-message="L'identifiant est obligatoire" />
<input class="form-control" type="text" name="login" value="${login}" />
</div>
<div class="form-group">
<input class="form-control" type="password" name="password" value=""
placeholder="Mot de passe"
data-fv-notempty="true"
data-fv-notempty-message="Le mot de passe est obligatoire">
<input class="form-control" type="password" name="password" value="" />
</div>
<div class="form-group">
<button class="btn btn-primary" type="submit" name="form.submitted">Se connecter</button>
<button id="submitButton" class="btn btn-primary" type="submit" name="form.submitted">Se connecter</button>
&nbsp;&nbsp;
</div>
<p class="help-block">
@@ -49,9 +39,38 @@
<script>
$(document).ready(function() {
$('#login-form').formValidation();
$('#login-form').formValidation({
framework: 'bootstrap',
message: 'This value is not valid',
icon: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
login: {
validators: {
notEmpty: {
message: 'Le code utilisateur est obligatoire'
},
}
},
password: {
validators: {
notEmpty: {
message: 'Le mot de passe est obligatoire'
}
}
}
}
});
$('form input').on('keypress', function(e) {
return e.which !== 13;
var code = e.keyCode || e.which;
if (code === 13) {
e.preventDefault();
// simuler clic bouton submit
document.getElementById("submitButton").click();
}
});
});
</script>