Project

General

Profile

1 2214 jones
// JavaScript Document
2
3
var popupMsg = "If you need to create a new account, \n"
4
			  +"click the \"create new account\" link \n"
5
			  +"beneath the password text-box";
6
7
function allowSubmit(formObj) {
8
9
  if (trim(formObj.elements["loginAction"].value)!="Login") return true;
10
11
  //trim username & passwd:
12
  var username = trim(formObj.elements["username"].value);
13
  var organization  = trim(formObj.elements["organization"].value);
14
  var password      = trim(formObj.elements["password"].value);
15
16
  if (username=="") {
17
    alert("You must type a username. \n"+popupMsg);
18
	formObj.elements["username"].focus();
19
    return false;
20
  }
21
22
  if (organization=="") {
23
    alert("You must select an organization. \n"+popupMsg);
24
	formObj.elements["organization"].focus();
25
    return false;
26
  }
27
28
  if (password=="") {
29
    alert("You must type a password. \n"+popupMsg);
30
	formObj.elements["password"].focus();
31
    return false;
32
  }
33
  return true;
34
}
35
36
function allowSearch(formObj) {
37
38
  var canSearch = true;
39
  var searchString = trim(formObj.elements["anyfield"].value);
40
  if (searchString=="") {
41 7537 leinfelder
    if (confirm("Show *all* data?\n(this may take some time!)")) {
42 2214 jones
	  formObj.elements["anyfield"].value = "%";
43
	  canSearch = true;
44
	} else {
45
	  formObj.elements["anyfield"].focus();
46
	  canSearch = false;
47
	}
48
  }
49
  return canSearch;
50
}
51
52
53
function allowAdvancedSearch(inputFormObj, submitFormObj) {
54
55
  var searchString = trim(inputFormObj.elements["searchValue"].value);
56
57
  if (searchString=="") searchString="%";
58
59
  if (inputFormObj.searchField.value=='anyfield') {
60
61
    submitFormObj.anyfield.value=searchString;
62
63
  } else if (inputFormObj.searchField.value=='title') {
64
65
    submitFormObj.title.value=searchString;
66
67
  } else if (inputFormObj.searchField.value=='surname') {
68
69
    submitFormObj.surName.value=searchString;
70
  }
71
  return true;
72
}
73
74
function keywordSearch(formObj, searchKeyword) {
75
76
  var searchString = trim(searchKeyword);
77
78
  if (searchString=="") searchString="%";
79
80
  formObj.anyfield.value=searchString;
81
82
  formObj.submit();
83
84
  return true;
85
}
86
87
function trim(stringToTrim) {
88
89
  return stringToTrim.replace(/^\s*/, '').replace(/\s*$/,'');
90
}