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)); activate($(this).attr('name'), $(this));
}); });
$('form').submit(validateAll);
activate('database', $('[name="database"]')); 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) { function activate(type, el) {
var field = el.val(), var field = el.val(),
parent = el.parents('.input-row'), parent = el.parents('.input-row'),

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

Loading…
Cancel
Save