You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

683 lines
26 KiB

4 years ago
  1. //CdnPath=http://ajax.aspnetcdn.com/ajax/4.5.1/1/WebUIValidation.js
  2. var Page_ValidationVer = "125";
  3. var Page_IsValid = true;
  4. var Page_BlockSubmit = false;
  5. var Page_InvalidControlToBeFocused = null;
  6. var Page_TextTypes = /^(text|password|file|search|tel|url|email|number|range|color|datetime|date|month|week|time|datetime-local)$/i;
  7. function ValidatorUpdateDisplay(val) {
  8. if (typeof(val.display) == "string") {
  9. if (val.display == "None") {
  10. return;
  11. }
  12. if (val.display == "Dynamic") {
  13. val.style.display = val.isvalid ? "none" : "inline";
  14. return;
  15. }
  16. }
  17. if ((navigator.userAgent.indexOf("Mac") > -1) &&
  18. (navigator.userAgent.indexOf("MSIE") > -1)) {
  19. val.style.display = "inline";
  20. }
  21. val.style.visibility = val.isvalid ? "hidden" : "visible";
  22. }
  23. function ValidatorUpdateIsValid() {
  24. Page_IsValid = AllValidatorsValid(Page_Validators);
  25. }
  26. function AllValidatorsValid(validators) {
  27. if ((typeof(validators) != "undefined") && (validators != null)) {
  28. var i;
  29. for (i = 0; i < validators.length; i++) {
  30. if (!validators[i].isvalid) {
  31. return false;
  32. }
  33. }
  34. }
  35. return true;
  36. }
  37. function ValidatorHookupControlID(controlID, val) {
  38. if (typeof(controlID) != "string") {
  39. return;
  40. }
  41. var ctrl = document.getElementById(controlID);
  42. if ((typeof(ctrl) != "undefined") && (ctrl != null)) {
  43. ValidatorHookupControl(ctrl, val);
  44. }
  45. else {
  46. val.isvalid = true;
  47. val.enabled = false;
  48. }
  49. }
  50. function ValidatorHookupControl(control, val) {
  51. if (typeof(control.tagName) != "string") {
  52. return;
  53. }
  54. if (control.tagName != "INPUT" && control.tagName != "TEXTAREA" && control.tagName != "SELECT") {
  55. var i;
  56. for (i = 0; i < control.childNodes.length; i++) {
  57. ValidatorHookupControl(control.childNodes[i], val);
  58. }
  59. return;
  60. }
  61. else {
  62. if (typeof(control.Validators) == "undefined") {
  63. control.Validators = new Array;
  64. var eventType;
  65. if (control.type == "radio") {
  66. eventType = "onclick";
  67. } else {
  68. eventType = "onchange";
  69. if (typeof(val.focusOnError) == "string" && val.focusOnError == "t") {
  70. ValidatorHookupEvent(control, "onblur", "ValidatedControlOnBlur(event); ");
  71. }
  72. }
  73. ValidatorHookupEvent(control, eventType, "ValidatorOnChange(event); ");
  74. if (Page_TextTypes.test(control.type)) {
  75. ValidatorHookupEvent(control, "onkeypress",
  76. "event = event || window.event; if (!ValidatedTextBoxOnKeyPress(event)) { event.cancelBubble = true; if (event.stopPropagation) event.stopPropagation(); return false; } ");
  77. }
  78. }
  79. control.Validators[control.Validators.length] = val;
  80. }
  81. }
  82. function ValidatorHookupEvent(control, eventType, functionPrefix) {
  83. var ev = control[eventType];
  84. if (typeof(ev) == "function") {
  85. ev = ev.toString();
  86. ev = ev.substring(ev.indexOf("{") + 1, ev.lastIndexOf("}"));
  87. }
  88. else {
  89. ev = "";
  90. }
  91. control[eventType] = new Function("event", functionPrefix + " " + ev);
  92. }
  93. function ValidatorGetValue(id) {
  94. var control;
  95. control = document.getElementById(id);
  96. if (typeof(control.value) == "string") {
  97. return control.value;
  98. }
  99. return ValidatorGetValueRecursive(control);
  100. }
  101. function ValidatorGetValueRecursive(control)
  102. {
  103. if (typeof(control.value) == "string" && (control.type != "radio" || control.checked == true)) {
  104. return control.value;
  105. }
  106. var i, val;
  107. for (i = 0; i<control.childNodes.length; i++) {
  108. val = ValidatorGetValueRecursive(control.childNodes[i]);
  109. if (val != "") return val;
  110. }
  111. return "";
  112. }
  113. function Page_ClientValidate(validationGroup) {
  114. Page_InvalidControlToBeFocused = null;
  115. if (typeof(Page_Validators) == "undefined") {
  116. return true;
  117. }
  118. var i;
  119. for (i = 0; i < Page_Validators.length; i++) {
  120. ValidatorValidate(Page_Validators[i], validationGroup, null);
  121. }
  122. ValidatorUpdateIsValid();
  123. ValidationSummaryOnSubmit(validationGroup);
  124. Page_BlockSubmit = !Page_IsValid;
  125. return Page_IsValid;
  126. }
  127. function ValidatorCommonOnSubmit() {
  128. Page_InvalidControlToBeFocused = null;
  129. var result = !Page_BlockSubmit;
  130. if ((typeof(window.event) != "undefined") && (window.event != null)) {
  131. window.event.returnValue = result;
  132. }
  133. Page_BlockSubmit = false;
  134. return result;
  135. }
  136. function ValidatorEnable(val, enable) {
  137. val.enabled = (enable != false);
  138. ValidatorValidate(val);
  139. ValidatorUpdateIsValid();
  140. }
  141. function ValidatorOnChange(event) {
  142. event = event || window.event;
  143. Page_InvalidControlToBeFocused = null;
  144. var targetedControl;
  145. if ((typeof(event.srcElement) != "undefined") && (event.srcElement != null)) {
  146. targetedControl = event.srcElement;
  147. }
  148. else {
  149. targetedControl = event.target;
  150. }
  151. var vals;
  152. if (typeof(targetedControl.Validators) != "undefined") {
  153. vals = targetedControl.Validators;
  154. }
  155. else {
  156. if (targetedControl.tagName.toLowerCase() == "label") {
  157. targetedControl = document.getElementById(targetedControl.htmlFor);
  158. vals = targetedControl.Validators;
  159. }
  160. }
  161. if (vals) {
  162. for (var i = 0; i < vals.length; i++) {
  163. ValidatorValidate(vals[i], null, event);
  164. }
  165. }
  166. ValidatorUpdateIsValid();
  167. }
  168. function ValidatedTextBoxOnKeyPress(event) {
  169. event = event || window.event;
  170. if (event.keyCode == 13) {
  171. ValidatorOnChange(event);
  172. var vals;
  173. if ((typeof(event.srcElement) != "undefined") && (event.srcElement != null)) {
  174. vals = event.srcElement.Validators;
  175. }
  176. else {
  177. vals = event.target.Validators;
  178. }
  179. return AllValidatorsValid(vals);
  180. }
  181. return true;
  182. }
  183. function ValidatedControlOnBlur(event) {
  184. event = event || window.event;
  185. var control;
  186. if ((typeof(event.srcElement) != "undefined") && (event.srcElement != null)) {
  187. control = event.srcElement;
  188. }
  189. else {
  190. control = event.target;
  191. }
  192. if ((typeof(control) != "undefined") && (control != null) && (Page_InvalidControlToBeFocused == control)) {
  193. control.focus();
  194. Page_InvalidControlToBeFocused = null;
  195. }
  196. }
  197. function ValidatorValidate(val, validationGroup, event) {
  198. val.isvalid = true;
  199. if ((typeof(val.enabled) == "undefined" || val.enabled != false) && IsValidationGroupMatch(val, validationGroup)) {
  200. if (typeof(val.evaluationfunction) == "function") {
  201. val.isvalid = val.evaluationfunction(val);
  202. if (!val.isvalid && Page_InvalidControlToBeFocused == null &&
  203. typeof(val.focusOnError) == "string" && val.focusOnError == "t") {
  204. ValidatorSetFocus(val, event);
  205. }
  206. }
  207. }
  208. ValidatorUpdateDisplay(val);
  209. }
  210. function ValidatorSetFocus(val, event) {
  211. var ctrl;
  212. if (typeof(val.controlhookup) == "string") {
  213. var eventCtrl;
  214. if ((typeof(event) != "undefined") && (event != null)) {
  215. if ((typeof(event.srcElement) != "undefined") && (event.srcElement != null)) {
  216. eventCtrl = event.srcElement;
  217. }
  218. else {
  219. eventCtrl = event.target;
  220. }
  221. }
  222. if ((typeof(eventCtrl) != "undefined") && (eventCtrl != null) &&
  223. (typeof(eventCtrl.id) == "string") &&
  224. (eventCtrl.id == val.controlhookup)) {
  225. ctrl = eventCtrl;
  226. }
  227. }
  228. if ((typeof(ctrl) == "undefined") || (ctrl == null)) {
  229. ctrl = document.getElementById(val.controltovalidate);
  230. }
  231. if ((typeof(ctrl) != "undefined") && (ctrl != null) &&
  232. (ctrl.tagName.toLowerCase() != "table" || (typeof(event) == "undefined") || (event == null)) &&
  233. ((ctrl.tagName.toLowerCase() != "input") || (ctrl.type.toLowerCase() != "hidden")) &&
  234. (typeof(ctrl.disabled) == "undefined" || ctrl.disabled == null || ctrl.disabled == false) &&
  235. (typeof(ctrl.visible) == "undefined" || ctrl.visible == null || ctrl.visible != false) &&
  236. (IsInVisibleContainer(ctrl))) {
  237. if ((ctrl.tagName.toLowerCase() == "table" && (typeof(__nonMSDOMBrowser) == "undefined" || __nonMSDOMBrowser)) ||
  238. (ctrl.tagName.toLowerCase() == "span")) {
  239. var inputElements = ctrl.getElementsByTagName("input");
  240. var lastInputElement = inputElements[inputElements.length -1];
  241. if (lastInputElement != null) {
  242. ctrl = lastInputElement;
  243. }
  244. }
  245. if (typeof(ctrl.focus) != "undefined" && ctrl.focus != null) {
  246. ctrl.focus();
  247. Page_InvalidControlToBeFocused = ctrl;
  248. }
  249. }
  250. }
  251. function IsInVisibleContainer(ctrl) {
  252. if (typeof(ctrl.style) != "undefined" &&
  253. ( ( typeof(ctrl.style.display) != "undefined" &&
  254. ctrl.style.display == "none") ||
  255. ( typeof(ctrl.style.visibility) != "undefined" &&
  256. ctrl.style.visibility == "hidden") ) ) {
  257. return false;
  258. }
  259. else if (typeof(ctrl.parentNode) != "undefined" &&
  260. ctrl.parentNode != null &&
  261. ctrl.parentNode != ctrl) {
  262. return IsInVisibleContainer(ctrl.parentNode);
  263. }
  264. return true;
  265. }
  266. function IsValidationGroupMatch(control, validationGroup) {
  267. if ((typeof(validationGroup) == "undefined") || (validationGroup == null)) {
  268. return true;
  269. }
  270. var controlGroup = "";
  271. if (typeof(control.validationGroup) == "string") {
  272. controlGroup = control.validationGroup;
  273. }
  274. return (controlGroup == validationGroup);
  275. }
  276. function ValidatorOnLoad() {
  277. if (typeof(Page_Validators) == "undefined")
  278. return;
  279. var i, val;
  280. for (i = 0; i < Page_Validators.length; i++) {
  281. val = Page_Validators[i];
  282. if (typeof(val.evaluationfunction) == "string") {
  283. eval("val.evaluationfunction = " + val.evaluationfunction + ";");
  284. }
  285. if (typeof(val.isvalid) == "string") {
  286. if (val.isvalid == "False") {
  287. val.isvalid = false;
  288. Page_IsValid = false;
  289. }
  290. else {
  291. val.isvalid = true;
  292. }
  293. } else {
  294. val.isvalid = true;
  295. }
  296. if (typeof(val.enabled) == "string") {
  297. val.enabled = (val.enabled != "False");
  298. }
  299. if (typeof(val.controltovalidate) == "string") {
  300. ValidatorHookupControlID(val.controltovalidate, val);
  301. }
  302. if (typeof(val.controlhookup) == "string") {
  303. ValidatorHookupControlID(val.controlhookup, val);
  304. }
  305. }
  306. Page_ValidationActive = true;
  307. }
  308. function ValidatorConvert(op, dataType, val) {
  309. function GetFullYear(year) {
  310. var twoDigitCutoffYear = val.cutoffyear % 100;
  311. var cutoffYearCentury = val.cutoffyear - twoDigitCutoffYear;
  312. return ((year > twoDigitCutoffYear) ? (cutoffYearCentury - 100 + year) : (cutoffYearCentury + year));
  313. }
  314. var num, cleanInput, m, exp;
  315. if (dataType == "Integer") {
  316. exp = /^\s*[-\+]?\d+\s*$/;
  317. if (op.match(exp) == null)
  318. return null;
  319. num = parseInt(op, 10);
  320. return (isNaN(num) ? null : num);
  321. }
  322. else if(dataType == "Double") {
  323. exp = new RegExp("^\\s*([-\\+])?(\\d*)\\" + val.decimalchar + "?(\\d*)\\s*$");
  324. m = op.match(exp);
  325. if (m == null)
  326. return null;
  327. if (m[2].length == 0 && m[3].length == 0)
  328. return null;
  329. cleanInput = (m[1] != null ? m[1] : "") + (m[2].length>0 ? m[2] : "0") + (m[3].length>0 ? "." + m[3] : "");
  330. num = parseFloat(cleanInput);
  331. return (isNaN(num) ? null : num);
  332. }
  333. else if (dataType == "Currency") {
  334. var hasDigits = (val.digits > 0);
  335. var beginGroupSize, subsequentGroupSize;
  336. var groupSizeNum = parseInt(val.groupsize, 10);
  337. if (!isNaN(groupSizeNum) && groupSizeNum > 0) {
  338. beginGroupSize = "{1," + groupSizeNum + "}";
  339. subsequentGroupSize = "{" + groupSizeNum + "}";
  340. }
  341. else {
  342. beginGroupSize = subsequentGroupSize = "+";
  343. }
  344. exp = new RegExp("^\\s*([-\\+])?((\\d" + beginGroupSize + "(\\" + val.groupchar + "\\d" + subsequentGroupSize + ")+)|\\d*)"
  345. + (hasDigits ? "\\" + val.decimalchar + "?(\\d{0," + val.digits + "})" : "")
  346. + "\\s*$");
  347. m = op.match(exp);
  348. if (m == null)
  349. return null;
  350. if (m[2].length == 0 && hasDigits && m[5].length == 0)
  351. return null;
  352. cleanInput = (m[1] != null ? m[1] : "") + m[2].replace(new RegExp("(\\" + val.groupchar + ")", "g"), "") + ((hasDigits && m[5].length > 0) ? "." + m[5] : "");
  353. num = parseFloat(cleanInput);
  354. return (isNaN(num) ? null : num);
  355. }
  356. else if (dataType == "Date") {
  357. var yearFirstExp = new RegExp("^\\s*((\\d{4})|(\\d{2}))([-/]|\\. ?)(\\d{1,2})\\4(\\d{1,2})\\.?\\s*$");
  358. m = op.match(yearFirstExp);
  359. var day, month, year;
  360. if (m != null && (((typeof(m[2]) != "undefined") && (m[2].length == 4)) || val.dateorder == "ymd")) {
  361. day = m[6];
  362. month = m[5];
  363. year = (m[2].length == 4) ? m[2] : GetFullYear(parseInt(m[3], 10));
  364. }
  365. else {
  366. if (val.dateorder == "ymd"){
  367. return null;
  368. }
  369. var yearLastExp = new RegExp("^\\s*(\\d{1,2})([-/]|\\. ?)(\\d{1,2})(?:\\s|\\2)((\\d{4})|(\\d{2}))(?:\\s\u0433\\.|\\.)?\\s*$");
  370. m = op.match(yearLastExp);
  371. if (m == null) {
  372. return null;
  373. }
  374. if (val.dateorder == "mdy") {
  375. day = m[3];
  376. month = m[1];
  377. }
  378. else {
  379. day = m[1];
  380. month = m[3];
  381. }
  382. year = ((typeof(m[5]) != "undefined") && (m[5].length == 4)) ? m[5] : GetFullYear(parseInt(m[6], 10));
  383. }
  384. month -= 1;
  385. var date = new Date(year, month, day);
  386. if (year < 100) {
  387. date.setFullYear(year);
  388. }
  389. return (typeof(date) == "object" && year == date.getFullYear() && month == date.getMonth() && day == date.getDate()) ? date.valueOf() : null;
  390. }
  391. else {
  392. return op.toString();
  393. }
  394. }
  395. function ValidatorCompare(operand1, operand2, operator, val) {
  396. var dataType = val.type;
  397. var op1, op2;
  398. if ((op1 = ValidatorConvert(operand1, dataType, val)) == null)
  399. return false;
  400. if (operator == "DataTypeCheck")
  401. return true;
  402. if ((op2 = ValidatorConvert(operand2, dataType, val)) == null)
  403. return true;
  404. switch (operator) {
  405. case "NotEqual":
  406. return (op1 != op2);
  407. case "GreaterThan":
  408. return (op1 > op2);
  409. case "GreaterThanEqual":
  410. return (op1 >= op2);
  411. case "LessThan":
  412. return (op1 < op2);
  413. case "LessThanEqual":
  414. return (op1 <= op2);
  415. default:
  416. return (op1 == op2);
  417. }
  418. }
  419. function CompareValidatorEvaluateIsValid(val) {
  420. var value = ValidatorGetValue(val.controltovalidate);
  421. if (ValidatorTrim(value).length == 0)
  422. return true;
  423. var compareTo = "";
  424. if ((typeof(val.controltocompare) != "string") ||
  425. (typeof(document.getElementById(val.controltocompare)) == "undefined") ||
  426. (null == document.getElementById(val.controltocompare))) {
  427. if (typeof(val.valuetocompare) == "string") {
  428. compareTo = val.valuetocompare;
  429. }
  430. }
  431. else {
  432. compareTo = ValidatorGetValue(val.controltocompare);
  433. }
  434. var operator = "Equal";
  435. if (typeof(val.operator) == "string") {
  436. operator = val.operator;
  437. }
  438. return ValidatorCompare(value, compareTo, operator, val);
  439. }
  440. function CustomValidatorEvaluateIsValid(val) {
  441. var value = "";
  442. if (typeof(val.controltovalidate) == "string") {
  443. value = ValidatorGetValue(val.controltovalidate);
  444. if ((ValidatorTrim(value).length == 0) &&
  445. ((typeof(val.validateemptytext) != "string") || (val.validateemptytext != "true"))) {
  446. return true;
  447. }
  448. }
  449. var args = { Value:value, IsValid:true };
  450. if (typeof(val.clientvalidationfunction) == "string") {
  451. eval(val.clientvalidationfunction + "(val, args) ;");
  452. }
  453. return args.IsValid;
  454. }
  455. function RegularExpressionValidatorEvaluateIsValid(val) {
  456. var value = ValidatorGetValue(val.controltovalidate);
  457. if (ValidatorTrim(value).length == 0)
  458. return true;
  459. var rx = new RegExp(val.validationexpression);
  460. var matches = rx.exec(value);
  461. return (matches != null && value == matches[0]);
  462. }
  463. function ValidatorTrim(s) {
  464. var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
  465. return (m == null) ? "" : m[1];
  466. }
  467. function RequiredFieldValidatorEvaluateIsValid(val) {
  468. return (ValidatorTrim(ValidatorGetValue(val.controltovalidate)) != ValidatorTrim(val.initialvalue))
  469. }
  470. function RangeValidatorEvaluateIsValid(val) {
  471. var value = ValidatorGetValue(val.controltovalidate);
  472. if (ValidatorTrim(value).length == 0)
  473. return true;
  474. return (ValidatorCompare(value, val.minimumvalue, "GreaterThanEqual", val) &&
  475. ValidatorCompare(value, val.maximumvalue, "LessThanEqual", val));
  476. }
  477. function ValidationSummaryOnSubmit(validationGroup) {
  478. if (typeof(Page_ValidationSummaries) == "undefined")
  479. return;
  480. var summary, sums, s;
  481. var headerSep, first, pre, post, end;
  482. for (sums = 0; sums < Page_ValidationSummaries.length; sums++) {
  483. summary = Page_ValidationSummaries[sums];
  484. if (!summary) continue;
  485. summary.style.display = "none";
  486. if (!Page_IsValid && IsValidationGroupMatch(summary, validationGroup)) {
  487. var i;
  488. if (summary.showsummary != "False") {
  489. summary.style.display = "";
  490. if (typeof(summary.displaymode) != "string") {
  491. summary.displaymode = "BulletList";
  492. }
  493. switch (summary.displaymode) {
  494. case "List":
  495. headerSep = "<br>";
  496. first = "";
  497. pre = "";
  498. post = "<br>";
  499. end = "";
  500. break;
  501. case "BulletList":
  502. default:
  503. headerSep = "";
  504. first = "<ul>";
  505. pre = "<li>";
  506. post = "</li>";
  507. end = "</ul>";
  508. break;
  509. case "SingleParagraph":
  510. headerSep = " ";
  511. first = "";
  512. pre = "";
  513. post = " ";
  514. end = "<br>";
  515. break;
  516. }
  517. s = "";
  518. if (typeof(summary.headertext) == "string") {
  519. s += summary.headertext + headerSep;
  520. }
  521. s += first;
  522. for (i=0; i<Page_Validators.length; i++) {
  523. if (!Page_Validators[i].isvalid && typeof(Page_Validators[i].errormessage) == "string") {
  524. s += pre + Page_Validators[i].errormessage + post;
  525. }
  526. }
  527. s += end;
  528. summary.innerHTML = s;
  529. window.scrollTo(0,0);
  530. }
  531. if (summary.showmessagebox == "True") {
  532. s = "";
  533. if (typeof(summary.headertext) == "string") {
  534. s += summary.headertext + "\r\n";
  535. }
  536. var lastValIndex = Page_Validators.length - 1;
  537. for (i=0; i<=lastValIndex; i++) {
  538. if (!Page_Validators[i].isvalid && typeof(Page_Validators[i].errormessage) == "string") {
  539. switch (summary.displaymode) {
  540. case "List":
  541. s += Page_Validators[i].errormessage;
  542. if (i < lastValIndex) {
  543. s += "\r\n";
  544. }
  545. break;
  546. case "BulletList":
  547. default:
  548. s += "- " + Page_Validators[i].errormessage;
  549. if (i < lastValIndex) {
  550. s += "\r\n";
  551. }
  552. break;
  553. case "SingleParagraph":
  554. s += Page_Validators[i].errormessage + " ";
  555. break;
  556. }
  557. }
  558. }
  559. alert(s);
  560. }
  561. }
  562. }
  563. }
  564. if (window.jQuery) {
  565. (function ($) {
  566. var dataValidationAttribute = "data-val",
  567. dataValidationSummaryAttribute = "data-valsummary",
  568. normalizedAttributes = { validationgroup: "validationGroup", focusonerror: "focusOnError" };
  569. function getAttributesWithPrefix(element, prefix) {
  570. var i,
  571. attribute,
  572. list = {},
  573. attributes = element.attributes,
  574. length = attributes.length,
  575. prefixLength = prefix.length;
  576. prefix = prefix.toLowerCase();
  577. for (i = 0; i < length; i++) {
  578. attribute = attributes[i];
  579. if (attribute.specified && attribute.name.substr(0, prefixLength).toLowerCase() === prefix) {
  580. list[attribute.name.substr(prefixLength)] = attribute.value;
  581. }
  582. }
  583. return list;
  584. }
  585. function normalizeKey(key) {
  586. key = key.toLowerCase();
  587. return normalizedAttributes[key] === undefined ? key : normalizedAttributes[key];
  588. }
  589. function addValidationExpando(element) {
  590. var attributes = getAttributesWithPrefix(element, dataValidationAttribute + "-");
  591. $.each(attributes, function (key, value) {
  592. element[normalizeKey(key)] = value;
  593. });
  594. }
  595. function dispose(element) {
  596. var index = $.inArray(element, Page_Validators);
  597. if (index >= 0) {
  598. Page_Validators.splice(index, 1);
  599. }
  600. }
  601. function addNormalizedAttribute(name, normalizedName) {
  602. normalizedAttributes[name.toLowerCase()] = normalizedName;
  603. }
  604. function parseSpecificAttribute(selector, attribute, validatorsArray) {
  605. return $(selector).find("[" + attribute + "='true']").each(function (index, element) {
  606. addValidationExpando(element);
  607. element.dispose = function () { dispose(element); element.dispose = null; };
  608. if ($.inArray(element, validatorsArray) === -1) {
  609. validatorsArray.push(element);
  610. }
  611. }).length;
  612. }
  613. function parse(selector) {
  614. var length = parseSpecificAttribute(selector, dataValidationAttribute, Page_Validators);
  615. length += parseSpecificAttribute(selector, dataValidationSummaryAttribute, Page_ValidationSummaries);
  616. return length;
  617. }
  618. function loadValidators() {
  619. if (typeof (ValidatorOnLoad) === "function") {
  620. ValidatorOnLoad();
  621. }
  622. if (typeof (ValidatorOnSubmit) === "undefined") {
  623. window.ValidatorOnSubmit = function () {
  624. return Page_ValidationActive ? ValidatorCommonOnSubmit() : true;
  625. };
  626. }
  627. }
  628. function registerUpdatePanel() {
  629. if (window.Sys && Sys.WebForms && Sys.WebForms.PageRequestManager) {
  630. var prm = Sys.WebForms.PageRequestManager.getInstance(),
  631. postBackElement, endRequestHandler;
  632. if (prm.get_isInAsyncPostBack()) {
  633. endRequestHandler = function (sender, args) {
  634. if (parse(document)) {
  635. loadValidators();
  636. }
  637. prm.remove_endRequest(endRequestHandler);
  638. endRequestHandler = null;
  639. };
  640. prm.add_endRequest(endRequestHandler);
  641. }
  642. prm.add_beginRequest(function (sender, args) {
  643. postBackElement = args.get_postBackElement();
  644. });
  645. prm.add_pageLoaded(function (sender, args) {
  646. var i, panels, valFound = 0;
  647. if (typeof (postBackElement) === "undefined") {
  648. return;
  649. }
  650. panels = args.get_panelsUpdated();
  651. for (i = 0; i < panels.length; i++) {
  652. valFound += parse(panels[i]);
  653. }
  654. panels = args.get_panelsCreated();
  655. for (i = 0; i < panels.length; i++) {
  656. valFound += parse(panels[i]);
  657. }
  658. if (valFound) {
  659. loadValidators();
  660. }
  661. });
  662. }
  663. }
  664. $(function () {
  665. if (typeof (Page_Validators) === "undefined") {
  666. window.Page_Validators = [];
  667. }
  668. if (typeof (Page_ValidationSummaries) === "undefined") {
  669. window.Page_ValidationSummaries = [];
  670. }
  671. if (typeof (Page_ValidationActive) === "undefined") {
  672. window.Page_ValidationActive = false;
  673. }
  674. $.WebFormValidator = {
  675. addNormalizedAttribute: addNormalizedAttribute,
  676. parse: parse
  677. };
  678. if (parse(document)) {
  679. loadValidators();
  680. }
  681. registerUpdatePanel();
  682. });
  683. } (jQuery));
  684. }