| Line 64... |
Line 64... |
| 64 |
eval(targ+".location='"+url+selObj.options[selObj.selectedIndex].value+"'");
|
64 |
eval(targ+".location='"+url+selObj.options[selObj.selectedIndex].value+"'");
|
| 65 |
if (restore) selObj.selectedIndex=0;
|
65 |
if (restore) selObj.selectedIndex=0;
|
| 66 |
}
|
66 |
}
|
| 67 |
}
|
67 |
}
|
| 68 |
|
68 |
|
| - |
|
69 |
//
|
| - |
|
70 |
// Validate Forms
|
| - |
|
71 |
// Arguments:
|
| - |
|
72 |
// --Silent - Optional. Supresses alert
|
| - |
|
73 |
// Triplets - Zero or more triplets.
|
| - |
|
74 |
// Eg: 'FRpkgName','Package Name','RisPackage'
|
| - |
|
75 |
// FormObject - Form Object ID
|
| - |
|
76 |
// TextPrefix - Error message Prefix
|
| - |
|
77 |
// TestType - Type of test to perfom.
|
| - |
|
78 |
// First letter may be R - Required.
|
| - |
|
79 |
//
|
| 69 |
function MM_validateForm() { //v5.0
|
80 |
function MM_validateForm() {
|
| 70 |
var ii,p,pl,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
|
81 |
var ii,p,pl,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
|
| 71 |
var REresults;
|
82 |
var REresults;
|
| 72 |
var pass,passc;
|
83 |
var pass,passc;
|
| 73 |
var showAlert = true;
|
84 |
var showAlert = true;
|
| 74 |
|
85 |
|
| 75 |
// Other general validations
|
86 |
// Other general validations
|
| 76 |
var cleanStrRE = /^[0-9a-z_\.\(\)\-]+$/i;
|
87 |
var cleanStrRE = /^[0-9a-z_\.\(\)\-]+$/i;
|
| 77 |
var pkgRE = /^[a-z][a-z0-9_-]*[a-z0-9]$/i;
|
88 |
var pkgRE = /^[a-z][a-z0-9_-]*[a-z0-9]$/i;
|
| 78 |
var versionRE = /^[0-9a-z_\.\(\)\-]+$/i;
|
89 |
var versionRE = /^[0-9a-z_\.\(\)\-]+$/i;
|
| 79 |
var versionNumberRE = /^\d+\.\d+\.\d+$/;
|
- |
|
| 80 |
var re_patch_ver_format = /^\d+\.\d+\.\d+\.p\d+\.[a-zA-Z0-9]+$/;
|
90 |
var re_patch_ver_format = /^\d+\.\d+\.\d+\.p\d+\.[a-zA-Z0-9]+$/;
|
| 81 |
var urlRE = "^https?://[a-z1-9]";
|
91 |
var urlRE = "^https?://[a-z1-9]";
|
| 82 |
//character range disallowed
|
92 |
//character range disallowed
|
| 83 |
var HTMLchr = /[\<\>\'\"]+/i;
|
93 |
var HTMLchr = /[\<\>\'\"]+/i;
|
| 84 |
var alphanumRE = /^[a-z0-9]+$/i;
|
94 |
var alphanumRE = /^[a-z0-9]+$/i;
|
| 85 |
|
95 |
|
| 86 |
// Options are first
|
96 |
// Options are first
|
| 87 |
for (ii=0; ii<(args.length-2) && args[ii].indexOf('--') == 0; ii++) {
|
97 |
for (ii=0; ii<(args.length-2) && typeof(args[ii]) === 'string' && args[ii].indexOf('--') == 0; ii++) {
|
| 88 |
switch(args[ii].toLowerCase()) {
|
98 |
switch(args[ii].toLowerCase()) {
|
| 89 |
case "--silent" :
|
99 |
case "--silent" :
|
| 90 |
showAlert = false;
|
100 |
showAlert = false;
|
| 91 |
break;
|
101 |
break;
|
| 92 |
}
|
102 |
}
|
| Line 96... |
Line 106... |
| 96 |
// These are in triplets
|
106 |
// These are in triplets
|
| 97 |
// Name of form object - Value is extracted for user as 'val'
|
107 |
// Name of form object - Value is extracted for user as 'val'
|
| 98 |
// Text Prefix for error - 'nm'
|
108 |
// Text Prefix for error - 'nm'
|
| 99 |
// Type of Test to Perform -'test'
|
109 |
// Type of Test to Perform -'test'
|
| 100 |
for (; ii<(args.length-2); ii+=3) {
|
110 |
for (; ii<(args.length-2); ii+=3) {
|
| - |
|
111 |
nm=args[ii+1];
|
| 101 |
test=args[ii+2];
|
112 |
test=args[ii+2];
|
| - |
|
113 |
if ( typeof(args[ii]) === 'string' ) {
|
| 102 |
val=MM_findObj(args[ii]);
|
114 |
val=MM_findObj(args[ii]);
|
| 103 |
|
- |
|
| 104 |
if (val) {
|
115 |
if (val) {
|
| 105 |
nm=args[ii+1];
|
- |
|
| 106 |
val=val.value;
|
116 |
val=val.value;
|
| 107 |
|
117 |
|
| 108 |
if (val!="") {
|
118 |
if (val!="") {
|
| 109 |
if (test.indexOf('isEmail')!=-1) {
|
119 |
if (test.indexOf('isEmail')!=-1) {
|
| 110 |
p=val.indexOf('@');
|
120 |
p=val.indexOf('@');
|
| 111 |
if (p<1 || p==(val.length-1) || test.charAt(0) == '@') errors+='- '+nm+' must contain an e-mail address.\n';
|
121 |
if (p<1 || p==(val.length-1) || test.charAt(0) == '@') errors+='- '+nm+' must contain an e-mail address.\n';
|
| 112 |
}
|
122 |
}
|
| 113 |
|
123 |
|
| 114 |
if (test.indexOf('isDate') != -1) {
|
124 |
if (test.indexOf('isDate') != -1) {
|
| 115 |
if (val.indexOf("/") != -1) {
|
125 |
if (val.indexOf("/") != -1) {
|
| 116 |
tmpARR = val.split("/");
|
126 |
tmpARR = val.split("/");
|
| 117 |
if (tmpARR.length == 3) {
|
127 |
if (tmpARR.length == 3) {
|
| 118 |
if (!(tmpARR[0]>0 && tmpARR[0]<32 && tmpARR[1]>0 && tmpARR[1]<13 && tmpARR[2]>1900 && tmpARR[2]<9999)) {
|
128 |
if (!(tmpARR[0]>0 && tmpARR[0]<32 && tmpARR[1]>0 && tmpARR[1]<13 && tmpARR[2]>1900 && tmpARR[2]<9999)) {
|
| 119 |
errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
|
129 |
errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
|
| 120 |
}
|
130 |
}
|
| 121 |
} else {
|
131 |
} else {
|
| 122 |
errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
|
132 |
errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
|
| 123 |
}
|
133 |
}
|
| 124 |
} else {
|
134 |
} else {
|
| 125 |
errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
|
135 |
errors += '- '+nm+' must be in DD/MM/YYYY format.\n';
|
| - |
|
136 |
}
|
| - |
|
137 |
}
|
| - |
|
138 |
|
| - |
|
139 |
if (test.indexOf('isPackage')!=-1) {
|
| - |
|
140 |
REresults = val.search(pkgRE);
|
| - |
|
141 |
if (REresults < 0) errors += val + ' - '+nm+' is not valid. Valid characters are A-Z a-z 0-9 - _\n'
|
| - |
|
142 |
+ 'Names must start with a letter and cannot contain spaces or symbols other than - and _\n';
|
| - |
|
143 |
}
|
| - |
|
144 |
|
| - |
|
145 |
if (test.indexOf('isCleanStr')!=-1) {
|
| - |
|
146 |
REresults = val.search(cleanStrRE);
|
| - |
|
147 |
if (REresults < 0) errors += val + '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
|
| - |
|
148 |
}
|
| - |
|
149 |
|
| - |
|
150 |
if (test.indexOf('isVersionStr')!=-1) {
|
| - |
|
151 |
REresults = val.search(versionRE);
|
| - |
|
152 |
if (REresults < 0) errors += val + '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
|
| 126 |
}
|
153 |
}
|
| - |
|
154 |
|
| - |
|
155 |
if (test.indexOf('isPatchVersionStr')!=-1) {
|
| - |
|
156 |
if ( !re_patch_ver_format.test(val) ) {
|
| - |
|
157 |
errors += val + '- '+nm+' is not of form (integer).(integer).(integer).p(integer).(extension)\n';
|
| - |
|
158 |
}
|
| 127 |
}
|
159 |
}
|
| 128 |
|
160 |
|
| 129 |
if (test.indexOf('isPackage')!=-1) {
|
- |
|
| 130 |
REresults = val.search(pkgRE);
|
- |
|
| 131 |
if (REresults < 0) errors += val + ' - '+nm+' is not valid. Valid characters are A-Z a-z 0-9 - _\n'
|
- |
|
| 132 |
+ 'Names must start with a letter and cannot contain spaces or symbols other than - and _\n';
|
- |
|
| 133 |
}
|
- |
|
| 134 |
|
- |
|
| 135 |
if (test.indexOf('isCleanStr')!=-1) {
|
161 |
if (test.indexOf('isCCPath')!=-1) {
|
| 136 |
REresults = val.search(cleanStrRE);
|
162 |
var CCPathRE = /^\\|\/[a-z]+[0-9a-z_\.\-\\\/ ]+$/i;
|
| 137 |
if (REresults < 0) errors += val + '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
|
- |
|
| 138 |
}
|
- |
|
| 139 |
|
163 |
|
| 140 |
if (test.indexOf('isVersionStr')!=-1) {
|
- |
|
| 141 |
REresults = val.search(versionRE);
|
- |
|
| 142 |
if (REresults < 0) errors += val + '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
|
- |
|
| 143 |
}
|
- |
|
| 144 |
|
- |
|
| 145 |
if (test.indexOf('isPatchVersionStr')!=-1) {
|
- |
|
| 146 |
if ( !re_patch_ver_format.test(val) ) {
|
- |
|
| 147 |
errors += val + '- '+nm+' is not of form (integer).(integer).(integer).p(integer).(extension)\n';
|
- |
|
| 148 |
}
|
- |
|
| 149 |
}
|
- |
|
| 150 |
|
- |
|
| 151 |
if (test.indexOf('isCCPath')!=-1) {
|
- |
|
| 152 |
var CCPathRE = /^\\|\/[a-z]+[0-9a-z_\.\-\\\/ ]+$/i;
|
- |
|
| 153 |
|
- |
|
| 154 |
REresults = val.search(/^(\\|\/)/);
|
164 |
REresults = val.search(/^(\\|\/)/);
|
| 155 |
if (REresults < 0) errors += val + '- '+nm+' must begin with \\ or /\n';
|
165 |
if (REresults < 0) errors += val + '- '+nm+' must begin with \\ or /\n';
|
| 156 |
|
166 |
|
| 157 |
REresults = val.search(CCPathRE);
|
167 |
REresults = val.search(CCPathRE);
|
| 158 |
if (REresults < 0) errors += val + '- '+nm+' uses invalid character.\nAllowed characters are \\ / A-Z a-z 0-9 . - _ SPACE\n';
|
168 |
if (REresults < 0) errors += val + '- '+nm+' uses invalid character.\nAllowed characters are \\ / A-Z a-z 0-9 . - _ SPACE\n';
|
| 159 |
}
|
169 |
}
|
| 160 |
|
170 |
|
| 161 |
if (test.indexOf('isCCLabel')!=-1) {
|
171 |
if (test.indexOf('isCCLabel')!=-1) {
|
| 162 |
var CCLabelRE = /^[0-9a-z_\.\-]+$/i;
|
172 |
var CCLabelRE = /^[0-9a-z_\.\-]+$/i;
|
| 163 |
|
173 |
|
| 164 |
REresults = val.search(CCLabelRE);
|
174 |
REresults = val.search(CCLabelRE);
|
| 165 |
if (REresults < 0) errors += val + '- '+nm+' uses invalid character.\nAllowed characters are A-Z a-z 0-9 . - _\n';
|
175 |
if (REresults < 0) errors += val + '- '+nm+' uses invalid character.\nAllowed characters are A-Z a-z 0-9 . - _\n';
|
| 166 |
}
|
176 |
}
|
| 167 |
|
177 |
|
| 168 |
if (test.indexOf('isSVNTag')!=-1) {
|
178 |
if (test.indexOf('isSVNTag')!=-1) {
|
| 169 |
// Subversion Tag validation
|
179 |
// Subversion Tag validation
|
| 170 |
var SVNTagValidPeg = /^@?\d+$/;
|
180 |
var SVNTagValidPeg = /^@?\d+$/;
|
| 171 |
var SVNTagRE = /^[0-9a-z_\.\-]+$/i;
|
181 |
var SVNTagRE = /^[0-9a-z_\.\-]+$/i;
|
| 172 |
|
182 |
|
| 173 |
if ( val.search(SVNTagValidPeg) < 0) {
|
183 |
if ( val.search(SVNTagValidPeg) < 0) {
|
| 174 |
|
- |
|
| 175 |
var stripped;
|
- |
|
| 176 |
stripped = val.replace (/@\d+$/,"");
|
- |
|
| 177 |
if (stripped.search(SVNTagRE) < 0)
|
- |
|
| 178 |
errors += val + '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
|
- |
|
| 179 |
}
|
- |
|
| 180 |
}
|
- |
|
| 181 |
|
184 |
|
| - |
|
185 |
var stripped;
|
| - |
|
186 |
stripped = val.replace (/@\d+$/,"");
|
| - |
|
187 |
if (stripped.search(SVNTagRE) < 0)
|
| - |
|
188 |
errors += val + '- '+nm+' uses invalid character. Allowed characters are A-Z a-z 0-9 . - _\n';
|
| - |
|
189 |
}
|
| - |
|
190 |
}
|
| - |
|
191 |
|
| 182 |
if (test.indexOf('isSVNPegTag')!=-1 && ! errors) {
|
192 |
if (test.indexOf('isSVNPegTag')!=-1 && ! errors) {
|
| 183 |
// Subversion Tag has peg - Must have done valid check first
|
193 |
// Subversion Tag has peg - Must have done valid check first
|
| 184 |
var SVNTagPegged = /@?\d+$/;
|
194 |
var SVNTagPegged = /@?\d+$/;
|
| 185 |
|
195 |
|
| 186 |
if ( val.search(SVNTagPegged) < 0) {
|
196 |
if ( val.search(SVNTagPegged) < 0) {
|
| 187 |
errors += val + '- '+nm+' Must be pegged for Manually Versioned Package. ie:tag@pegNumber\n';
|
197 |
errors += val + '- '+nm+' Must be pegged for Manually Versioned Package. ie:tag@pegNumber\n';
|
| 188 |
}
|
198 |
}
|
| 189 |
}
|
199 |
}
|
| 190 |
|
200 |
|
| 191 |
if (test.indexOf('isSVNPath')!=-1) {
|
201 |
if (test.indexOf('isSVNPath')!=-1) {
|
| 192 |
// Subversion Base Path validation
|
202 |
// Subversion Base Path validation
|
| 193 |
var SVNTagValidCharsRE = /^[0-9a-z_\.\-\/]+$/i;
|
203 |
var SVNTagValidCharsRE = /^[0-9a-z_\.\-\/]+$/i;
|
| 194 |
var SVNTagInValidSlashAtBOL = /^\/.*$/i;
|
204 |
var SVNTagInValidSlashAtBOL = /^\/.*$/i;
|
| 195 |
var SVNTagInValidSlashAtEOL = /\/$/i;
|
205 |
var SVNTagInValidSlashAtEOL = /\/$/i;
|
| 196 |
var SVNTagInValidSlash = /^.*\/\/.*$/i;
|
206 |
var SVNTagInValidSlash = /^.*\/\/.*$/i;
|
| 197 |
var SVNTagInValidTrunkAnywhereRE = /\/trunk\//i;
|
207 |
var SVNTagInValidTrunkAnywhereRE = /\/trunk\//i;
|
| 198 |
var SVNTagValidTagAnywhereRE = /^.*\/tags\/.*$/i;
|
208 |
var SVNTagValidTagAnywhereRE = /^.*\/tags\/.*$/i;
|
| 199 |
|
209 |
|
| 200 |
if (val.search(SVNTagValidCharsRE) < 0)
|
210 |
if (val.search(SVNTagValidCharsRE) < 0)
|
| 201 |
errors += val + ' - '+nm+' uses invalid character. Allowed characters are / A-Z a-z 0-9 . - _\n';
|
211 |
errors += val + ' - '+nm+' uses invalid character. Allowed characters are / A-Z a-z 0-9 . - _\n';
|
| 202 |
else if (val.search(SVNTagInValidSlashAtBOL) >= 0)
|
212 |
else if (val.search(SVNTagInValidSlashAtBOL) >= 0)
|
| 203 |
errors += val + ' - '+nm+' begins with a /. This is not allowed.\n';
|
213 |
errors += val + ' - '+nm+' begins with a /. This is not allowed.\n';
|
| 204 |
else if (val.search(SVNTagInValidSlashAtEOL) >= 0)
|
214 |
else if (val.search(SVNTagInValidSlashAtEOL) >= 0)
|
| 205 |
errors += val + ' - '+nm+' ends with a /. This is not allowed.\n';
|
215 |
errors += val + ' - '+nm+' ends with a /. This is not allowed.\n';
|
| 206 |
else if (val.search(SVNTagInValidSlash) >= 0)
|
216 |
else if (val.search(SVNTagInValidSlash) >= 0)
|
| 207 |
errors += val + ' - '+nm+' uses //. This is not allowed.\n';
|
217 |
errors += val + ' - '+nm+' uses //. This is not allowed.\n';
|
| 208 |
else if (val.search(SVNTagValidTagAnywhereRE) >= 0)
|
218 |
else if (val.search(SVNTagValidTagAnywhereRE) >= 0)
|
| 209 |
errors += val + ' - '+nm+' contains /tags/. This is not allowed.\n';
|
219 |
errors += val + ' - '+nm+' contains /tags/. This is not allowed.\n';
|
| 210 |
else if (val.search(SVNTagInValidTrunkAnywhereRE) >= 0)
|
220 |
else if (val.search(SVNTagInValidTrunkAnywhereRE) >= 0)
|
| 211 |
errors += val + ' - '+nm+' contains /trunk/. This is not allowed.\n';
|
221 |
errors += val + ' - '+nm+' contains /trunk/. This is not allowed.\n';
|
| 212 |
else {
|
222 |
else {
|
| 213 |
var bits = val.split("/");
|
223 |
var bits = val.split("/");
|
| 214 |
if ( bits.length < 4 )
|
224 |
if ( bits.length < 4 )
|
| 215 |
errors += val + ' - Must contain at least 4 path items.\n';
|
225 |
errors += val + ' - Must contain at least 4 path items.\n';
|
| 216 |
|
226 |
|
| 217 |
var ttbcount = 0;
|
227 |
var ttbcount = 0;
|
| 218 |
var i
|
228 |
var i
|
| 219 |
for (i=0; i < bits.length; i++ )
|
229 |
for (i=0; i < bits.length; i++ )
|
| 220 |
{
|
230 |
{
|
| 221 |
var el = bits[i];
|
231 |
var el = bits[i];
|
| 222 |
if ( el == 'tags') ttbcount++;
|
232 |
if ( el == 'tags') ttbcount++;
|
| 223 |
if ( el == 'trunk') ttbcount++;
|
233 |
if ( el == 'trunk') ttbcount++;
|
| 224 |
if ( el == 'branches') ttbcount++;
|
234 |
if ( el == 'branches') ttbcount++;
|
| 225 |
}
|
235 |
}
|
| 226 |
if ( ttbcount != 1 )
|
236 |
if ( ttbcount != 1 )
|
| 227 |
errors += val + ' - '+nm+' must contain exactly one of tags, trunk or branches. It contains '+ttbcount+'.\n';
|
237 |
errors += val + ' - '+nm+' must contain exactly one of tags, trunk or branches. It contains '+ttbcount+'.\n';
|
| 228 |
|
238 |
|
| 229 |
if ( bits.pop() == 'branches' )
|
239 |
if ( bits.pop() == 'branches' )
|
| 230 |
errors += val + ' - '+nm+' must not end in branches.\n';
|
240 |
errors += val + ' - '+nm+' must not end in branches.\n';
|
| 231 |
|
241 |
|
| 232 |
}
|
242 |
}
|
| 233 |
}
|
243 |
}
|
| 234 |
|
244 |
|
| 235 |
// No longer used. See mm_ValidateVersion
|
245 |
// No longer used in this simple form
|
| 236 |
if (test.indexOf('isVersionNumber')!=-1) {
|
246 |
if (test.indexOf('isVersionNumber')!=-1) {
|
| 237 |
REresults = val.search(versionNumberRE);
|
247 |
REresults = -1;
|
| 238 |
if (REresults < 0) errors += val + ' - '+nm+' is formatted incorrectly.\nVersion number should be (major).(minor).(patch)(build)\ne.g. 1.0.2002\n';
|
248 |
if (REresults < 0) errors += val + ' - '+nm+' isVersionNumber is no longer supported in this form';
|
| 239 |
}
|
249 |
}
|
| 240 |
|
250 |
|
| 241 |
if (test.indexOf('isURL')!=-1) {
|
251 |
if (test.indexOf('isURL')!=-1) {
|
| 242 |
REresults = val.match(urlRE);
|
252 |
REresults = val.match(urlRE);
|
| 243 |
if (REresults == null) errors += '"'+val+'" is not a valid URL.\n';
|
253 |
if (REresults == null) errors += '"'+val+'" is not a valid URL.\n';
|
| 244 |
}
|
254 |
}
|
| 245 |
|
255 |
|
| 246 |
if (test.indexOf('isAlphaNum')!=-1) {
|
256 |
if (test.indexOf('isAlphaNum')!=-1) {
|
| 247 |
REresults = val.match(alphanumRE);
|
257 |
REresults = val.match(alphanumRE);
|
| 248 |
if (REresults == null) errors += '"'+nm+'" must be an alphanumeric value.\n';
|
258 |
if (REresults == null) errors += '"'+nm+'" must be an alphanumeric value.\n';
|
| 249 |
}
|
259 |
}
|
| 250 |
|
260 |
|
| 251 |
if (test.indexOf('isChangePassword')!=-1) {
|
261 |
if (test.indexOf('isChangePassword')!=-1) {
|
| 252 |
pass=MM_findObj('FRpassword');
|
262 |
pass=MM_findObj('FRpassword');
|
| 253 |
passc=MM_findObj('FRpasswordc');
|
263 |
passc=MM_findObj('FRpasswordc');
|
| 254 |
if (pass.value!=passc.value) errors+='- Password confirmation does not match.\n';
|
264 |
if (pass.value!=passc.value) errors+='- Password confirmation does not match.\n';
|
| 255 |
}
|
265 |
}
|
| 256 |
|
266 |
|
| 257 |
if (test.indexOf('maxLength')!=-1) {
|
267 |
if (test.indexOf('maxLength')!=-1) {
|
| 258 |
p=test.indexOf(':');
|
268 |
p=test.indexOf(':');
|
| 259 |
max=test.substring(p+1);
|
269 |
max=test.substring(p+1);
|
| 260 |
if (val.length>max) errors+='- '+nm+' can be maximum '+max+' characters long.\n';
|
270 |
if (val.length>max) errors+='- '+nm+' can be maximum '+max+' characters long.\n';
|
| 261 |
}
|
271 |
}
|
| 262 |
|
272 |
|
| 263 |
if (test.indexOf('notHTML')!=-1) {
|
273 |
if (test.indexOf('notHTML')!=-1) {
|
| 264 |
if (val.match(HTMLchr)) errors+='- '+nm+' has invalid characters like \'< > quotes\'\n';
|
274 |
if (val.match(HTMLchr)) errors+='- '+nm+' has invalid characters like \'< > quotes\'\n';
|
| 265 |
}
|
275 |
}
|
| 266 |
|
276 |
|
| 267 |
if (test.charAt(0)=='R') {
|
277 |
if (test.charAt(0)=='R') {
|
| 268 |
|
278 |
|
| 269 |
if (test.indexOf('isNumber') != -1) {
|
279 |
if (test.indexOf('isNumber') != -1) {
|
| 270 |
if (isNaN(val)) errors+='- '+nm+' must be a number.\n';
|
280 |
if (isNaN(val)) errors+='- '+nm+' must be a number.\n';
|
| 271 |
}
|
281 |
}
|
| 272 |
|
282 |
|
| 273 |
if (test.indexOf('inRange') != -1) {
|
283 |
if (test.indexOf('inRange') != -1) {
|
| 274 |
p=test.indexOf(':');
|
284 |
p=test.indexOf(':');
|
| 275 |
min=test.substring(8,p);
|
285 |
min=test.substring(8,p);
|
| 276 |
max=test.substring(p+1);
|
286 |
max=test.substring(p+1);
|
| 277 |
if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
|
287 |
if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
|
| 278 |
}
|
288 |
}
|
| 279 |
|
289 |
|
| 280 |
if (test.indexOf('inLength')!=-1) {
|
290 |
if (test.indexOf('inLength')!=-1) {
|
| 281 |
pl=test.indexOf('inLength')
|
291 |
pl=test.indexOf('inLength')
|
| 282 |
p=test.indexOf(':');
|
292 |
p=test.indexOf(':');
|
| 283 |
min=test.substring(pl+8,p);
|
293 |
min=test.substring(pl+8,p);
|
| 284 |
if (val.length<min) errors+='- '+nm+' must be at least '+min+' characters long.\n';
|
294 |
if (val.length<min) errors+='- '+nm+' must be at least '+min+' characters long.\n';
|
| 285 |
}
|
295 |
}
|
| 286 |
}
|
296 |
}
|
| 287 |
} else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n';
|
297 |
} else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n';
|
| 288 |
|
298 |
|
| 289 |
|
299 |
|
| 290 |
if (test.indexOf('isPassword')!=-1) {
|
300 |
if (test.indexOf('isPassword')!=-1) {
|
| 291 |
pass=MM_findObj('FRpassword');
|
301 |
pass=MM_findObj('FRpassword');
|
| 292 |
passc=MM_findObj('FRpasswordc');
|
302 |
passc=MM_findObj('FRpasswordc');
|
| 293 |
if (!MM_findObj('FRdomainauth').checked) {
|
303 |
if (!MM_findObj('FRdomainauth').checked) {
|
| 294 |
if (test.indexOf('inLength')!=-1) {
|
304 |
if (test.indexOf('inLength')!=-1) {
|
| 295 |
pl=test.indexOf('inLength')
|
305 |
pl=test.indexOf('inLength')
|
| 296 |
p=test.indexOf(':');
|
306 |
p=test.indexOf(':');
|
| 297 |
min=test.substring(pl+8,p);
|
307 |
min=test.substring(pl+8,p);
|
| 298 |
if (val.length<min) errors+='- '+nm+' must be at least '+min+' characters long.\n';
|
308 |
if (val.length<min) errors+='- '+nm+' must be at least '+min+' characters long.\n';
|
| 299 |
}
|
309 |
}
|
| 300 |
if (pass.value!=passc.value) errors+='- Password confirmation does not match.\n';
|
310 |
if (pass.value!=passc.value) errors+='- Password confirmation does not match.\n';
|
| 301 |
} else {
|
311 |
} else {
|
| 302 |
if (MM_findObj('FRdomain_name').value=="") errors += '- Domain Name is required.\n';
|
312 |
if (MM_findObj('FRdomain_name').value=="") errors += '- Domain Name is required.\n';
|
| 303 |
}
|
313 |
}
|
| 304 |
}
|
314 |
}
|
| 305 |
|
315 |
|
| 306 |
if (test.indexOf('isDomainName')!=-1) {
|
316 |
if (test.indexOf('isDomainName')!=-1) {
|
| 307 |
if (MM_findObj('FRdomainauth').checked) {
|
317 |
if (MM_findObj('FRdomainauth').checked) {
|
| 308 |
if (MM_findObj('FRdomain_name').value=="") errors += '- Domain Name is required.\n';
|
318 |
if (MM_findObj('FRdomain_name').value=="") errors += '- Domain Name is required.\n';
|
| - |
|
319 |
}
|
| 309 |
}
|
320 |
}
|
| - |
|
321 |
}
|
| - |
|
322 |
}
|
| - |
|
323 |
else {
|
| - |
|
324 |
// Alternate form. First item is an object
|
| - |
|
325 |
// Contents are test specific
|
| - |
|
326 |
var valp = args[ii];
|
| - |
|
327 |
|
| - |
|
328 |
// Expects object with data to examine
|
| - |
|
329 |
if (test.indexOf('isVersionNumber')!=-1) {
|
| - |
|
330 |
var rv = MM_ValidateVersion(valp.vBase, valp.vExt, valp.isAuto || false, valp.isPatch || false);
|
| - |
|
331 |
if ( rv )
|
| - |
|
332 |
errors += '- ' +nm+rv;
|
| 310 |
}
|
333 |
}
|
| 311 |
}
|
334 |
}
|
| 312 |
}
|
335 |
}
|
| 313 |
|
336 |
|
| 314 |
if (errors) {
|
337 |
if (errors) {
|
| 315 |
if ( showAlert )
|
338 |
if ( showAlert )
|
| Line 335... |
Line 358... |
| 335 |
var pb = MM_findObj('ProgressBar');
|
358 |
var pb = MM_findObj('ProgressBar');
|
| 336 |
if ( pb )
|
359 |
if ( pb )
|
| 337 |
pb.style.visibility='hidden';
|
360 |
pb.style.visibility='hidden';
|
| 338 |
}
|
361 |
}
|
| 339 |
|
362 |
|
| 340 |
|
- |
|
| 341 |
function isChecked(boxName, buttonId) {
|
363 |
function isChecked(boxName, buttonId) {
|
| 342 |
var formButton = document.getElementById(buttonId);
|
364 |
var formButton = document.getElementById(buttonId);
|
| 343 |
var boxes = document.getElementsByName(boxName);
|
365 |
var boxes = document.getElementsByName(boxName);
|
| 344 |
var btnChecked = false;
|
366 |
var btnChecked = false;
|
| 345 |
if (formButton) {
|
367 |
if (formButton) {
|
| Line 537... |
Line 559... |
| 537 |
}
|
559 |
}
|
| 538 |
}
|
560 |
}
|
| 539 |
|
561 |
|
| 540 |
//////////////////////////////////////////////////////////////////////////////////////////////////
|
562 |
//////////////////////////////////////////////////////////////////////////////////////////////////
|
| 541 |
//
|
563 |
//
|
| 542 |
// MM_ValidateVersion(pkgName, versionBase, versionExt, isAutobuild)
|
564 |
// MM_ValidateVersion(versionBase, versionExt, isAutobuild isPatch)
|
| - |
|
565 |
// Should NOT be used externally. Use MM_validateForm to access this function
|
| 543 |
//
|
566 |
//
|
| 544 |
// pkgName eg EA_DocGen
|
- |
|
| 545 |
// versionBase eg 1.2.3
|
567 |
// versionBase eg 1.2.3
|
| 546 |
// versionExt eg .cr
|
568 |
// versionExt eg .cr
|
| 547 |
// isAutobuild true or false
|
- |
|
| 548 |
// isPatch true or false
|
- |
|
| 549 |
//
|
- |
|
| 550 |
// Returns true if version is valid, else false
|
- |
|
| 551 |
//
|
- |
|
| 552 |
// This function can and should be used instead of MM_validateForm to validate
|
- |
|
| 553 |
// version numbers for new or reversioned package versions.
|
- |
|
| 554 |
//
|
- |
|
| 555 |
// So far, this function is used in the following situations:
|
- |
|
| 556 |
// 1) Add new version to release (_form_new_version_page.asp)
|
- |
|
| 557 |
// 2) Reversion existing version (_wform_rename_version.asp)
|
- |
|
| 558 |
// 3) Add package to release (Form_add_pkg_versions.asp)
|
- |
|
| 559 |
//////////////////////////////////////////////////////////////////////////////////////////////////
|
- |
|
| 560 |
function MM_ValidateVersion(pkgName, versionBase, versionExt, isAutobuild, isPatch)
|
- |
|
| 561 |
{
|
- |
|
| 562 |
var errString = MM_ValidateVersionReturningErrString(pkgName, versionBase, versionExt, isAutobuild, isPatch);
|
- |
|
| 563 |
if (errString.length > 0)
|
- |
|
| 564 |
{
|
- |
|
| 565 |
alert(errString);
|
- |
|
| 566 |
return false;
|
- |
|
| 567 |
}
|
- |
|
| 568 |
return true;
|
- |
|
| 569 |
}
|
- |
|
| 570 |
|
- |
|
| 571 |
//////////////////////////////////////////////////////////////////////////////////////////////////
|
- |
|
| 572 |
//
|
- |
|
| 573 |
// MM_ValidateVersionReturningErrString(pkgName, versionBase, versionExt, isAutobuild)
|
- |
|
| 574 |
//
|
- |
|
| 575 |
// pkgName eg buildtool
|
- |
|
| 576 |
// versionBase eg 1.2.3
|
- |
|
| 577 |
// versionExt eg .cr
|
- |
|
| 578 |
// isAutobuild true or false
|
569 |
// isAutobuild true or false
|
| 579 |
// isPatch true or false
|
570 |
// isPatch true or false
|
| 580 |
//
|
571 |
//
|
| 581 |
// Returns a non-zero-length error string if version is NOT valid, else returns a zero-length string
|
572 |
// Returns a non-zero-length error string if version is NOT valid, else returns a zero-length string
|
| 582 |
//
|
573 |
//
|
| 583 |
// The MM_validateForm function should be modified to use this if possible, although I currently
|
- |
|
| 584 |
// do not believe it has access to all the necessary parameter values needed.
|
- |
|
| 585 |
//
|
- |
|
| 586 |
//////////////////////////////////////////////////////////////////////////////////////////////////
|
574 |
//////////////////////////////////////////////////////////////////////////////////////////////////
|
| 587 |
function MM_ValidateVersionReturningErrString(pkgName, versionBase, versionExt, isAutobuild, isPatch)
|
575 |
function MM_ValidateVersion(versionBase, versionExt, isAutobuild, isPatch)
|
| 588 |
{
|
576 |
{
|
| 589 |
var re_std_ver_format = /^\d+\.\d+\.\d+$/;
|
577 |
var re_std_ver_format = /^\d+\.\d+\.\d+$/;
|
| 590 |
var re_patch_ver_format = /^\d+\.\d+\.\d+\.p\d+$/;
|
578 |
var re_patch_ver_format = /^\d+\.\d+\.\d+\.p\d+$/;
|
| 591 |
var re_cots_ver_format = /^[\w]+[\w\.\-]*$/; // starts with letter or digit or underscore, subsequent chars can be letters or digits or _ or . or -
|
579 |
var re_cots_ver_format = /^[\w]+[\w\.\-]*$/; // starts with letter or digit or underscore, subsequent chars can be letters or digits or _ or . or -
|
| 592 |
var re_cots_ver_format_exc1 = /[-_.]+[-_.]+/; // look for any two adjacent special characters
|
580 |
var re_cots_ver_format_exc1 = /[-_.]+[-_.]+/; // look for any two adjacent special characters
|
| 593 |
var re_cots_ver_format_exc2 = /[0-9A-Za-z]+/; // look for any alphanumeric char
|
581 |
var re_cots_ver_format_exc2 = /[0-9A-Za-z]+/; // look for any alphanumeric char
|
| - |
|
582 |
var isCots = versionExt == ".cots" || versionExt == ".tool";
|
| 594 |
|
583 |
|
| 595 |
var forPkgName = "";
|
584 |
if (!isAutobuild) {
|
| 596 |
if (pkgName != null && pkgName.length > 0)
|
585 |
if ( versionBase.length == 0 ) {
|
| 597 |
{
|
- |
|
| 598 |
forPkgName = ", for package " + pkgName;
|
586 |
return " is of zero length";
|
| 599 |
}
|
- |
|
| 600 |
|
- |
|
| 601 |
if (!isAutobuild)
|
587 |
} else if ( !isCots) {
|
| 602 |
{
|
- |
|
| 603 |
if ( versionBase.length == 0 )
|
588 |
if ( isPatch ) {
|
| 604 |
{
|
- |
|
| 605 |
return "Action failed: version number is of zero length" + forPkgName;
|
589 |
if ( !re_patch_ver_format.test(versionBase) ) {
|
| 606 |
}
|
- |
|
| 607 |
else if ( versionExt != ".cots" && versionExt != ".tool")
|
590 |
return " is not of form (integer).(integer).(integer).p(integer)";
|
| 608 |
{
|
- |
|
| 609 |
if ( isPatch )
|
591 |
}
|
| 610 |
{
|
592 |
} else {
|
| 611 |
if ( !re_patch_ver_format.test(versionBase) )
|
593 |
if ( !re_std_ver_format.test(versionBase) ) {
|
| 612 |
{
|
- |
|
| 613 |
return "Action failed: patch version is not of form (integer).(integer).(integer).p(integer).(extension)" + forPkgName;
|
594 |
return " is not of form (integer).(integer).(integer)";
|
| 614 |
}
|
595 |
}
|
| 615 |
}
|
596 |
}
|
| 616 |
else
|
- |
|
| 617 |
{
|
- |
|
| 618 |
if ( !re_std_ver_format.test(versionBase) )
|
- |
|
| 619 |
{
|
597 |
} else if (isCots) {
|
| 620 |
return "Action failed: version is not of form (integer).(integer).(integer).(extension)" + forPkgName;
|
- |
|
| 621 |
}
|
- |
|
| 622 |
}
|
- |
|
| 623 |
}
|
- |
|
| 624 |
else if ( versionExt == ".cots" || versionExt == ".tool")
|
- |
|
| 625 |
{
|
- |
|
| 626 |
var extName = versionExt.toUpperCase().substr(1);
|
598 |
var extName = versionExt.toUpperCase().substr(1);
|
| 627 |
|
599 |
|
| 628 |
if ( !re_cots_ver_format.test(versionBase) )
|
600 |
if ( !re_cots_ver_format.test(versionBase) ) {
|
| 629 |
{
|
- |
|
| 630 |
return "Action failed: " + extName + " version must begin with letter/digit/underscore, cannot contain any whitespace, and only special characters underscore/dash/dot are allowed" + forPkgName;
|
601 |
return " " + extName + " package must begin with letter/digit/underscore, cannot contain any whitespace, and only special characters underscore/dash/dot are allowed";
|
| 631 |
}
|
602 |
}
|
| 632 |
|
603 |
|
| 633 |
if ( re_cots_ver_format_exc1.test(versionBase) )
|
604 |
if ( re_cots_ver_format_exc1.test(versionBase) ) {
|
| 634 |
{
|
- |
|
| 635 |
return "Action failed: " + extName + " version cannot contain two adjacent special characters (underscore/dash/dot)" + forPkgName;
|
605 |
return " " + extName + " package cannot contain two adjacent special characters (underscore/dash/dot)";
|
| 636 |
}
|
606 |
}
|
| 637 |
|
607 |
|
| 638 |
if ( !re_cots_ver_format_exc2.test(versionBase) )
|
608 |
if ( !re_cots_ver_format_exc2.test(versionBase) ) {
|
| 639 |
{
|
- |
|
| 640 |
return "Action failed: " + extName + " version must contain one or more alphanumeric characters" + forPkgName;
|
609 |
return " " + extName + " package must contain one or more alphanumeric characters";
|
| 641 |
}
|
610 |
}
|
| 642 |
}
|
611 |
}
|
| 643 |
}
|
612 |
}
|
| 644 |
|
613 |
|
| 645 |
// everything ok - no error
|
614 |
// everything ok - no error
|