1var Validator = { 2 errorId: '__error_', 3 existsErrorId: 'isExistsError', 4 errorGroupNotExistClassName: 'errorMessage', 5 errorGroupClassName: 'errorMessage alertMsg alertMsg-error', 6 check : function(field, reg, extra) { 7 var response; 8 var rule = this.rule; 9 rule.field = field; 10 rule.value = field.value; 11 rule.extra = extra; 12 13 if (reg == "input") { 14 response = rule.input(); 15 } else if (reg && !response && rule.value != '') { 16 reg = reg.replace(/^!/, ''); 17 18 var mode = reg.split(/\s+/); 19 for ( var i = 0, m; m = mode[i]; i++) { 20 m = m.replace(/([\d?\.\-:]+)?$/, ''); 21 response = rule[m](RegExp.$1); 22 if (response) { 23 break; 24 } 25 } 26 } 27 28 if (response) { 29 this.output(field, response); 30 return false; 31 } else { 32 return true; 33 } 34 }, 35 36 checkTel : function(telId, telNo) { 37 var response; 38 var rule = this.rule; 39 rule.value = telNo; 40 41 response = rule.tel(); 42 if (response) { 43 this.outputbyId(telId, response); 44 return false; 45 } else { 46 return true; 47 } 48 }, 49 50 checkZip : function(zipId, zipNo) { 51 var response; 52 var rule = this.rule; 53 rule.value = zipNo; 54 55 response = rule.zip(); 56 if (response) { 57 this.outputbyId(zipId, response); 58 return false; 59 } else { 60 return true; 61 } 62 }, 63 64 allclose : function(form) { 65 for (var i = 0, f; f = form[i]; i++) { 66 this.init(f); 67 } 68 }, 69 70 init : function(field) { 71 if (field == null || field == undefined) { 72 return; 73 } 74 75 var id = field.id; 76 if (field.type == 'radio' || field.type == 'checkbox') { 77 id = id.replace(/_0$/, ''); 78 } 79 80 var className = field.className; 81 if (!isNullorUndefinedorEmpty(className)) { 82 if (className.indexOf("TEL_1") >= 0 || className.indexOf("ZIP_1") >= 0) { 83 id = id.replace('Pre', ''); 84 } else if (className.indexOf("TEL_2") >= 0) { 85 id = id.replace('Middle', ''); 86 } else if (className.indexOf("TEL_3") >= 0 || className.indexOf("ZIP_2") >= 0) { 87 id = id.replace('Post', ''); 88 } 89 } 90 91 this.initbyId(id); 92 }, 93 94 initbyId : function(id, msg) { 95 var errorId = this.errorId + id; 96 var errorElement = document.getElementById(errorId); 97 if (errorElement != null && errorElement != undefined) { 98 if (errorElement.innerHTML != undefined) { 99 errorElement.innerHTML = ""; 100 101 if(!this.isExistErrorMessageWithScreenError()){ 102 var existsErrorElement = document.getElementById(this.existsErrorId); 103 if (existsErrorElement != null && existsErrorElement != undefined) { 104 existsErrorElement.innerHTML = ""; 105 existsErrorElement.className = this.errorGroupNotExistClassName; 106 } 107 } 108 } 109 } 110 }, 111 112 output : function(field, msg) { 113 if (field == null || field == undefined || msg == null || msg == undefined || msg == "") { 114 return; 115 } 116 117 var id = field.id; 118 if (field.type == 'radio' || field.type == 'checkbox') { 119 id = id.replace(/_0$/, ''); 120 } 121 var className = field.className; 122 if (!isNullorUndefinedorEmpty(className)) { 123 if (className.indexOf("TEL_1") >= 0 || className.indexOf("ZIP_1") >= 0) { 124 id = id.replace('Pre', ''); 125 } else if (className.indexOf("TEL_2") >= 0) { 126 id = id.replace('Middle', ''); 127 } else if (className.indexOf("TEL_3") >= 0 || className.indexOf("ZIP_2") >= 0) { 128 id = id.replace('Post', ''); 129 } 130 } 131 this.outputbyId(id, msg); 132 }, 133 134 outputbyId : function(id, msg) { 135 var errorId = this.errorId + id; 136 var errorElement = document.getElementById(errorId); 137 if (errorElement != null && errorElement != undefined) { 138 var systemMessageContents = document.getElementsByClassName('systemMessageContent'); 139 for (var i = 0; i < systemMessageContents.length; i++) { 140 var systemMessageContent = systemMessageContents[i]; 141 systemMessageContent.remove(); 142 } 143 144 if (this.isExistSameErrorThisChildElements(errorElement, msg)) { 145 return; 146 } 147 148 var outputError = document.createElement('span'); 149 outputError.className = 'alertMessage alertMessageContent alertMessage-important'; 150 outputError.innerHTML = msg; 151 errorElement.appendChild(outputError); 152 153 var existsErrorElement = document.getElementById(this.existsErrorId); 154 if (existsErrorElement != null && existsErrorElement != undefined) { 155 existsErrorElement.className = this.errorGroupClassName; 156 157 var errorExistMessage = this.rule.submit(); 158 if (existsErrorElement.innerHTML.indexOf(errorExistMessage) < 0) { 159 var outputExistsError = document.createElement('span'); 160 outputExistsError.className = 'alertMessageContentTitle'; 161 outputExistsError.innerHTML = errorExistMessage; 162 existsErrorElement.innerHTML = outputExistsError.outerHTML; 163 } 164 } 165 } 166 }, 167 168 isExistSameErrorThisChildElements : function(errorElement, msg) { 169 if (isNullorUndefined(errorElement)) { 170 return false; 171 } 172 173 if (isNullorUndefined(errorElement.childNodes) || errorElement.childNodes.length == 0) { 174 return false; 175 } 176 177 var childNodes = errorElement.childNodes; 178 for (var i = 0; i < childNodes.length; i++) { 179 var child = childNodes[i];
180 if (isNullorUndefined(child) || isNullorUndefinedorEmpty(child.innerHTML)) { 181 continue; 182 } 183 if (child.innerHTML.indexOf(msg) >= 0) { 184 return true; 185 } 186 } 187 return false; 188 }, 189 190 getAlertMessageContents : function() { 191 return $('.alertMessage'); 192 }, 193 194 isExistErrorMessage : function() { 195 var alertMessageContents = this.getAlertMessageContents(); 196 if (alertMessageContents.length > 0) { 197 return true; 198 } else { 199 return false; 200 } 201 }, 202 203 isExistErrorMessageWithScreenError : function() { 204 var alertMessageContents = $('.alertMessageContent'); 205 if (alertMessageContents.length > 0) { 206 return true; 207 } else { 208 return false; 209 } 210 }, 211 212 focusToFirstErrorElement : function() { 213 var alertMessageContents = this.getAlertMessageContents(); 214 if (alertMessageContents.length == 0) { 215 return false; 216 } 217 218 for (var i = 0; i < alertMessageContents.length; i++) { 219 var alertMessageContent = alertMessageContents[0]; 220 var alertMessageContentParent = alertMessageContent.parentNode; 221 if (isNullorUndefined(alertMessageContentParent)) { 222 continue; 223 } 224 225 var alertMessageContentParentId = alertMessageContentParent.id; 226 if (isNullorUndefinedorEmpty(alertMessageContentParentId)) { 227 continue; 228 } 229 230 var targetFocusId = alertMessageContentParentId.replace(new RegExp("^" + this.errorId), ""); 231 focusToItem(targetFocusId); 232 return true; 233 } 234 return false; 235 }, 236 237 tohalf : function(str) { 238 if (str == null || str == undefined || str == "") { 239 return ""; 240 } 241 242 var half = str.replace(/[A-Zï½-ï½ï¼-ï¼]/g, function(s) { 243 return String.fromCharCode(s.charCodeAt(0) - 0xFEE0); 244 }); 245 246 half = half.replace(/ï¼/g, "."); 247 half = half.replace(/[ã¼ï¼]/g, "-"); 248 half = half.replace(/ï¼/g, ":"); 249 250 return half; 251 } 252}; 253 254Validator.rule = { 255 msg : null, 256 257 submit : function() { 258 return this.msg.submit; 259 }, 260 261 input : function() { 262 if (this.field.type == 'radio' || this.field.type == 'checkbox') { 263 for (var i = 0, e; ; i++) { 264 e = this.field.form[this.field.name][i]; 265 if (e == null || e == undefined) { 266 break; 267 } 268 if (e.checked) { 269 return; 270 } 271 } 272 // åä¸ãã§ãã¯ããã¯ã¹ã®å ´åã®å¤å® 273 var singleChecked = this.field.form[this.field.name].checked; 274 if (singleChecked != null && singleChecked != undefined && singleChecked) { 275 return; 276 } 277 return this.msg.noselect; 278 } else if (this.value == '') { 279 return (this.field.type == 'select-one' || this.field.type == 'select-multiple') ? this.msg.noselect 280 : this.msg.noinput; 281 } 282 }, 283 284 mail: function() { 285 this.tohalf(); 286 this.toLower(); 287 if (!this.value.match(/^([0-9A-Za-z\-+/~?#=&`{}_]+(\.[0-9A-Za-z\-+/~?#=&`{}_]+)*)@(?:[0-9A-Za-z]+(?:[-.][0-9A-Za-z]+)*\.[0-9A-Za-z]+(?:[-.][0-9A-Za-z]+)*)$/)) { 288 return this.msg.mail; 289 } 290 }, 291 292 equal : function() { 293 if (this.field.form[this.extra].value 294 && this.value != this.field.form[this.extra].value) { 295 return this.msg.unequal; 296 } 297 }, 298 299 alphabet : function() { 300 this.tohalf(); 301 if (!this.value.match(/^[a-zA-Z]+$/)) { 302 return this.msg.alphabet; 303 } 304 }, 305 306 alphabet_with_camma : function() { 307 this.tohalf(); 308 if (!this.value.match(/^[a-zA-Z,]+$/)) { 309 return this.msg.alphabet; 310 } 311 }, 312
313 alphabetNumber : function() { 314 this.tohalf(); 315 if (!this.value.match(/^[\x01-\x7F]+$/)) { 316 return this.msg.alphabetNumber; 317 } 318 }, 319 320 kana : function() { 321 for (var i = 0; i < this.value.length; i++) { 322 if (this.value.charAt(i) == ' ' || this.value.charAt(i) == '\u3000'){ 323 continue; 324 } 325 if ((this.value.charAt(i) < '\u30A1' 326 || this.value.charAt(i) > '\u30F6') && this.value.charAt(i) !== '\u30FC') { 327 return this.msg.kana; 328 } 329 } 330 }, 331 332 hiragana : function() { 333 if (!this.value.match(/^[ã-ãï¼-ï¼ï¼¡-Zï½-ï½ã¼ã]*$/)) { 334 return this.msg.hiragana; 335 } 336 }, 337 338 zenkaku : function() { 339 if (!this.value.match(/^[ï¼-ï¼ï¼¡-Zï½-ï½ã-ãã¡-ã¶ä¸-é¾ ã ï¼ã¼ï¼ï¼ ãã½ã¾ãããã»]*$/)) { 340 return this.msg.zenkaku; 341 } 342 }, 343 344 tel : function() { 345 if (!this.value.match(/^\d{2,5}-\d{1,4}-\d{3,4}$/) || !this.value.match(/^[\d-]{12,13}$/)) { 346 return this.msg.tel; 347 } 348 }, 349 350 zip : function() { 351 if (!this.value.match(/^[\d]{3}\-[\d]{4}$/)) { 352 return this.msg.zip; 353 } 354 }, 355 356 password : function() { 357 if (!this.value.match(/^[A-Za-z0-9`'\)|\+\{_=:\?\[@!\(\]\$>*-\}&<^;/~,"\.#%\\]*$/)) { 358 return this.msg.password; 359 } 360 }, 361 362 count : function(arg) { 363 return this._range(arg, this.value.length, this.msg.count); 364 }, 365 366 num : function(arg) { 367 this.tohalf(); 368 if (!this.value.match(/^[\d,\.-]+$/)) { 369 return this.msg.num.nonumber; 370 } 371 // ã«ã³ããå¤ã 372 var number = this.value.replace(/,/g, ""); 373 return this._range(arg, parseFloat(number), this.msg.num); 374 }, 375 376 numCount : function(arg) { 377 // ã«ã³ããå¤ã 378 var number = this.value.replace(/,/g, ""); 379 // å°æ°ç¹ä»¥ä¸ãã¹ããªãã 380 number = number.split("\.")[0]; 381 // ãã¤ãã¹ã¯æ¡æ°ã«æ°ããªã 382 number = number.replace(/-/g, ""); 383 return this._range(arg, number.length, this.msg.numCount); 384 }, 385 386 check : function(arg) { 387 var value = 0; 388 for ( var i = 0, e; e = this.field.form[this.field.name][i]; i++){ 389 if (e.checked) { 390 value += 1; 391 } 392 } 393 394 return this._range(arg, value, this.msg.check); 395 }, 396 397 tohalf : function() { 398 var half = Validator.tohalf(this.value); 399 this.field.value = half; 400 this.value = half; 401 }, 402 403 _range : function(range, value, msg) { 404 if (!range) 405 return; 406 407 var result = ''; 408 var c = (" " + range).split(/:/); 409 410 var isSetMin = true; 411 var min = parseFloat(c[0]); 412 if (min.toString() == "NaN") { 413 isSetMin = false; 414 } 415 416 var isSetMax = true; 417 var max = parseFloat(c[1]); 418 if (max.toString() == "NaN") { 419 isSetMax = false; 420 } 421 if (isSetMin && value != min && /^\d+$/.test(range)) { 422 result = msg.unequal; 423 } else if (!isSetMin && value > max) { 424 result = msg.too_big; 425 } else if (!isSetMax && value < min) { 426 result = msg.too_small; 427 } else if (isSetMin && isSetMax && (value < min || value > max)) { 428 result = msg.outofrange; 429 } 430 return result.replace(/%1/g, min).replace(/%2/g, max); 431 }, 432 433 toLower : function() { 434 // å ¨ã¦å°æåã«å¤æ 435 var inputText = this.value; 436 this.value = inputText.toLowerCase(); 437 this.field.value = inputText.toLowerCase(); 438 } 439}; 440 441Validator.lang = { 442 ja : { 443 noselect : 'å¿ é 鏿é ç®ã§ãã鏿ãã¦ãã ããã', 444 noinput : 'å¿ é å ¥åé ç®ã§ããå ¥åãã¦ãã ããã', 445 unequal : 'å ¥åãæã£ã¦ãã¾ããã', 446 447 submit : 'ã¨ã©ã¼ãããã¾ãã', 448 mail : 'æ£ããå½¢å¼ã®ã¡ã¼ã«ã¢ãã¬ã¹ãå ¥åãã¦ãã ããã', 449 alphabet : 'åè§ã®ã¢ã«ãã¡ããããå ¥åãã¦ãã ããã', 450 alphabetNumber : 'åè§ã®è±æ°æåãå ¥åãã¦ãã ããã', 451 kana : 'å ¨è§ã«ã¿ã«ãã§å ¥åãã¦ãã ããã', 452 hiragana : 'ã²ãããªãå ¥åãã¦ãã ããã', 453 zenkaku : 'å ¨è§æåãå ¥åãã¦ãã ããã', 454 tel : 'æ£ããå½¢å¼ã®é»è©±çªå·ãå ¥åãã¦ãã ããã', 455 zip : 'æ£ããå½¢å¼ã®éµä¾¿çªå·ãå ¥åãã¦ãã ããã', 456 password : 'æ£ããå½¢å¼ã®ãã¹ã¯ã¼ããå ¥åãã¦ãã ããã', 457 birthday : 'çå¹´ææ¥ãå ¥åãã¦ãã ããã', 458 459 count : {
460 unequal : '%1' + 'æåã§å ¥åãã¦ãã ããã', 461 too_big : '%2' + 'æå以ä¸ã§å ¥åãã¦ãã ããã', 462 too_small : '%1' + 'æå以ä¸ã§å ¥åãã¦ãã ããã', 463 outofrange : '%1' + 'æå以ä¸' + '%2' + 'æå以ä¸ã§å ¥åãã¦ãã ããã' 464 }, 465 466 num : { 467 nonumber : 'æ°å¤ãå ¥åãã¦ãã ããã', 468 unequal : '%1' + 'ã¨å ¥åãã¦ãã ããã', 469 too_big : '%2' + '以ä¸ã®å¤ãå ¥åãã¦ãã ããã', 470 too_small : '%1' + '以ä¸ã®å¤ãå ¥åãã¦ãã ããã', 471 outofrange : '%1' + 'ãã' + '%2' + 'ã®éã§å ¥åãã¦ãã ããã' 472 }, 473 474 numCount : { 475 unequal : '%1' + 'æ¡ã®å¤ãå ¥åãã¦ãã ããã', 476 too_big : '%2' + 'æ¡ä»¥ä¸ã®å¤ãå ¥åãã¦ãã ããã', 477 too_small : '%1' + 'æ¡ä»¥ä¸ã®å¤ãå ¥åãã¦ãã ããã', 478 outofrange : '%1' + 'æ¡ä»¥ä¸' + '%2' + 'æ¡ä»¥ä¸ã§å ¥åãã¦ãã ããã' 479 }, 480 481 check : { 482 unequal : 'ãã§ãã¯ã¯' + '%1' + 'åãã¦ãã ããã', 483 too_big : 'ãã§ãã¯ã¯' + '%2' + 'åã¾ã§ã§ãã', 484 too_small : 'ãã§ãã¯ã¯' + '%1' + 'å以ä¸ãã¦ãã ããã', 485 outofrange : 'ãã§ãã¯ã¯' + '%1' + 'åãã' + '%2' + 'åã¾ã§ã§ãã' 486 }, 487 488 date : { 489 nodate : 'æ£ããæ¥ä»ãå ¥åãã¦ãã ããã', 490 notime : 'æ£ããæå»ãå ¥åãã¦ãã ããã', 491 input_yyyymm : 'yyyy/MM ã®å½¢å¼ã§å ¥åãã¦ãã ããã', 492 input_yyyymmdd : 'yyyy/MM/dd ã®å½¢å¼ã§å ¥åãã¦ãã ããã', 493 input_yyyymmddhhmm : 'yyyy/MM/dd HH:mm ã®å½¢å¼ã§å ¥åãã¦ãã ããã', 494 input_yyyymmddhhmmss : 'yyyy/MM/dd HH:mm:ss ã®å½¢å¼ã§å ¥åãã¦ãã ããã', 495 input_yyyymmddhhmmsssss : 'yyyy/MM/dd HH:mm:ss sss ã®å½¢å¼ã§å ¥åãã¦ãã ããã', 496 input_hhmm : 'hh:mm ã®å½¢å¼ã§å ¥åãã¦ãã ããã' 497 }, 498 499 others : { 500 cleditor_init : 'å ¥åã䏿£ã®ããæ£ãã表示ã§ãã¾ãããã½ã¼ã¹ã¢ã¼ãã§ç¢ºèªãã¦ãã ããã' 501 } 502 } 503 504// ,en : { 505// noselect : '', 506// noinput : '', 507// unequal : '', 508// 509// submit : 'exists error.', 510// mail : '', 511// alphabet : '', 512// alphabetNumber : '', 513// kana : '',
514// zenkaku : '', 515// tel : '', 516// zip : '', 517// password : '', 518// birthday : '', 519// 520// count : { 521// unequal : '%1' + '', 522// too_big : '%2' + '', 523// too_small : '%1' + '', 524// outofrange : '%1' + '' + '%2' + '' 525// }, 526// 527// num : { 528// nonumber : '', 529// unequal : '%1' + '', 530// too_big : '%2' + '', 531// too_small : '%1' + '', 532// outofrange : '%1' + '' + '%2' + '' 533// }, 534// 535// numCount : { 536// unequal : '%1' + '', 537// too_big : '%2' + '', 538// too_small : '%1' + '', 539// outofrange : '%1' + '' + '%2' + '' 540// }, 541// 542// check : { 543// unequal : '' + '%1' + '', 544// too_big : '' + '%2' + '', 545// too_small : '' + '%1' + '', 546// outofrange : '' + '%1' + '' + '%2' + '' 547// }, 548// 549// date : { 550// nodate : '', 551// notime : '', 552// input_yyyymm : 'yyyy/MM', 553// input_yyyymmdd : 'yyyy/MM/dd', 554// input_yyyymmddhhmm : 'yyyy/MM/dd HH:mm', 555// input_yyyymmddhhmmss : 'yyyy/MM/dd HH:mm:ss', 556// input_yyyymmddhhmmsssss : 'yyyy/MM/dd HH:mm:ss sss', 557// input_hhmm : 'hh:mm' 558// } 559// } 560}; 561 562Validator.rule.msg = Validator.lang.ja;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.