From 220dec5711b1a1be9ea99fb61cf089d37d2627e3 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Wed, 22 Apr 2015 13:54:51 -0400 Subject: [PATCH] installer: validate before sending form --- public/src/installer/install.js | 15 ++++++ src/views/install/index.tpl | 85 +++++++++++++++++---------------- 2 files changed, 60 insertions(+), 40 deletions(-) diff --git a/public/src/installer/install.js b/public/src/installer/install.js index 1fa56e32d6..80d46bf337 100644 --- a/public/src/installer/install.js +++ b/public/src/installer/install.js @@ -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'), diff --git a/src/views/install/index.tpl b/src/views/install/index.tpl index 633fb870cb..5bf430e290 100644 --- a/src/views/install/index.tpl +++ b/src/views/install/index.tpl @@ -48,55 +48,60 @@ You are just a few steps away from launching your own NodeBB forum!

-

-

Create an Administrator account

-
-

-
-
- - +
+

+

Create an Administrator account

+
+

+ +
+
+ + +
+
-
-
-
-
- - +
+
+ + +
+
-
-
-
-
- - +
+
+ + +
+
-
-
-
-
- - +
+
+ + +
+
-
-

-

Configure your database

-
-

+
+

+

Configure your database

+
+

-
-
- - +
+
+ + +
-
-
+
+