installer: validate before sending form

v1.18.x
psychobunny 10 years ago
parent ee78281f35
commit 220dec5711

@ -22,9 +22,24 @@ $('document').ready(function() {
activate($(this).attr('name'), $(this));
});
$('form').submit(validateAll);
activate('database', $('[name="database"]'));
}
function validateAll(ev) {
$('form .admin [name]').each(function() {
activate($(this).attr('name'), $(this));
});
if ($('.error').length) {
ev.preventDefault();
$('html, body').animate({'scrollTop': '0px'}, 400);
return false;
}
}
function activate(type, el) {
var field = el.val(),
parent = el.parents('.input-row'),

@ -48,10 +48,12 @@
You are just a few steps away from launching your own NodeBB forum!
</p>
<form action="/" method="post">
<div class="admin">
<p>
<h1><small>Create an Administrator account</small></h1>
<hr />
</p>
<div class="row input-row">
<div class="col-sm-7 col-xs-12 input-field">
<label for="admin:username">Username</label>
@ -80,7 +82,9 @@
</div>
<div class="col-sm-5 help-text" data-help="Please confirm your password."></div>
</div>
</div>
<div class="database">
<p>
<h1><small>Configure your database</small></h1>
<hr />
@ -97,6 +101,7 @@
</div>
<div id="database-config"></div>
</div>
<button type="submit" class="btn btn-lg btn-success">Install NodeBB</button>
</form>

Loading…
Cancel
Save