1 ////////////////////////////////////////////////////////////////////////////////
3 // File: CVSAdmUtils.js
4 // Description: JavaScript routines for CVSAdm
5 // Author: Andrew@DeFaria.com
6 // Created: Wed May 12 13:47:39 PDT 2004
8 // Language: JavaScript
10 // (c) Copyright 2005, Andrew@DeFaria.com, all rights reserved.
12 ////////////////////////////////////////////////////////////////////////////////
13 function trim_trailing_spaces (str) {
14 // Strip trailing spaces
15 while (str.value.substr (str.value.length - 1) == " ") {
16 str.value = str.value.substr (0, (str.value.length - 1));
20 } // trim_trailing_spaces
22 function valid_email_address (email) {
23 var email_regex = /.+@.+\..+/;
25 return email_regex.test (email.value);
26 } // valid_email_address
28 function validate_login (login) {
30 userid = trim_trailing_spaces (userid);
32 if (userid.value == "") {
33 alert ("You must specify your Username!");
42 function validate_group (group) {
44 group = trim_trailing_spaces (group);
46 if (group.value == "") {
47 alert ("You must specify a group!");
56 function validate_sysuser (sysuser) {
58 sysuser = trim_trailing_spaces (sysuser);
60 if (sysuser.value == "") {
61 alert ("You must specify a sysuser!");
70 function validate_user (user) {
72 if (typeof username != "undefined") {
73 if (username.value == "") {
74 alert ("You must specify a Username");
81 "To change your password specify both your old and new passwords then\n" +
82 "repeat your new password in the fields provided.\n\n" +
83 "To leave your password unchanged leave old, new and repeated\n" +
84 "password fields blank.";
86 if (typeof old_password != "undefined") {
87 if (old_password.value != "") {
88 if (new_password.value == "") {
90 new_password.focus ();
93 if (new_password.value.length < 6) {
94 alert ("Passwords must be greater than 6 characters.");
95 new_password.focus ();
99 if (repeated_password.value == "") {
100 alert (password_msg);
101 repeated_password.focus ();
104 if (repeated_password.value.length < 6) {
105 alert ("Passwords must be greater than 6 characters.");
106 repeated_password.focus ();
110 if (new_password.value != repeated_password.value) {
111 alert ("Sorry but the new password and repeated password are not the same!");
112 new_password.focus ();
116 if (new_password.value != "") {
117 alert (password_msg);
118 new_password.focus ();
121 if (repeated_password.value != "") {
122 alert (password_msg);
123 repeated_password.focus ();
129 fullname = trim_trailing_spaces (fullname);
130 if (fullname.value == "") {
131 alert ("Full name is required!");
136 email = trim_trailing_spaces (email);
137 if (email.value == "") {
138 alert ("We need your email address - in case you forget your password\nand we need to send it to you.");
142 if (!valid_email_address (email)) {
143 alert ("That email address is invalid!\nMust be <username>@<domainname>\nFor example: Andrew@DeFaria.com.");
152 function AreYouSure (message) {
153 return window.confirm (message);