[vhffs-dev] [1900] JS validation on login page. |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1900
Author: beuss
Date: 2011-07-28 23:39:03 +0200 (Thu, 28 Jul 2011)
Log Message:
-----------
JS validation on login page.
Modified Paths:
--------------
trunk/vhffs-panel/Makefile.am
trunk/vhffs-panel/templates/anonymous/login.tt
Added Paths:
-----------
trunk/vhffs-panel/js/vhffs/anonymous/login.js
Modified: trunk/vhffs-panel/Makefile.am
===================================================================
--- trunk/vhffs-panel/Makefile.am 2011-07-28 21:38:55 UTC (rev 1899)
+++ trunk/vhffs-panel/Makefile.am 2011-07-28 21:39:03 UTC (rev 1900)
@@ -782,6 +782,7 @@
js/vhffs/nls/prompt.js \
js/vhffs/Menu.js \
js/vhffs/Common.js \
+ js/vhffs/anonymous/login.js \
js/vhffs/anonymous/subscribe.js \
js/tooltip.js
Added: trunk/vhffs-panel/js/vhffs/anonymous/login.js
===================================================================
--- trunk/vhffs-panel/js/vhffs/anonymous/login.js (rev 0)
+++ trunk/vhffs-panel/js/vhffs/anonymous/login.js 2011-07-28 21:39:03 UTC (rev 1900)
@@ -0,0 +1,27 @@
+dojo.addOnLoad(function() {
+ dojo.require("dojo.parser");
+ dojo.require("dijit.form.Form");
+ dojo.require("dijit.form.ValidationTextBox");
+
+ var infoImg = '<img src="/themes/light-grey/img/info.png" alt="info"/> ';
+
+ dojo.parser.instantiate( dojo.query("input.validation-identifier"), {
+ dojoType: "dijit.form.ValidationTextBox",
+ required: true,
+ regExp: "^[a-z0-9]{3,12}$"
+ });
+
+ dojo.parser.instantiate( dojo.query("input.validation-required"), {
+ dojoType: "dijit.form.ValidationTextBox",
+ required: true
+ });
+
+ dojo.parser.instantiate( [ dojo.byId("login-form") ], {
+ dojoType: "dijit.form.Form",
+ onSubmit: function(e) {
+ if(this.validate() == false) {
+ dojo.stopEvent(e);
+ }
+ }
+ });
+});
Modified: trunk/vhffs-panel/templates/anonymous/login.tt
===================================================================
--- trunk/vhffs-panel/templates/anonymous/login.tt 2011-07-28 21:38:55 UTC (rev 1899)
+++ trunk/vhffs-panel/templates/anonymous/login.tt 2011-07-28 21:39:03 UTC (rev 1900)
@@ -6,24 +6,24 @@
<h1>[% 'Welcome on %s' | i18n | pretty_print(hostname) %]</h1>
[% END %]
- <form class="table-like" action="/auth.pl" method="post" accept-charset="utf-8">
+ <form id="login-form" class="table-like" action="/auth.pl" method="post" accept-charset="utf-8">
<h2>[% 'Please enter your username and password' | i18n %]</h2>
[% INCLUDE 'misc/errors.tt' %]
[% INCLUDE 'misc/infos.tt' %]
<p>
- <label for="username">
+ <label for="login-username">
[% 'Username' | i18n | html %]
</label>
- <input type="text" tabindex="1" name="username" id="username" maxlength="32" value="[% username | html %]"/>
+ <input type="text" class="validation-identifier" tabindex="1" name="username" id="login-username" maxlength="32" value="[% username | html %]"/>
</p>
<p>
- <label for="password">
+ <label for="login-password">
[% 'Password' | i18n | html %]
</label>
- <input type="password" tabindex="2" name="password" id="password" maxlength="32" />
+ <input type="password" class="validation-required" tabindex="2" name="password" id="login-password" maxlength="32" />
</p>
<p class="button">
- <input type="submit" tabindex="3" value="[% 'Access to panel' | i18n %]" id="login_submit" name="login_submit"/>
+ <input type="submit" tabindex="3" value="[% 'Access to panel' | i18n %]" id="login-submit" name="login_submit"/>
</p>
</form>
<div id="sub_opts">
@@ -46,3 +46,4 @@
<p>[% 'Woah, %s users and %s groups already trust %s' | i18n | pretty_print(stats.users, stats.groups, hostname) | html %]</p>
[% END %]
</div>
+ <script type="text/javascript" charset="utf-8" src="/js/vhffs/anonymous/login.js"></script>