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.

1371 lines
39 KiB

  1. var isChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
  2. function LoadModule(menuType) {
  3. scroll(0, 0);
  4. return true;
  5. switch (menuType.toLowerCase()) {
  6. case "adminstration":
  7. window.open("/Administration.aspx?mtype=adminstration", "mainFrame")
  8. break;
  9. case "customer_management":
  10. window.open("/Administration.aspx?mtype=customer_management", "mainFrame")
  11. break;
  12. case "customer_management":
  13. window.open("/Administration.aspx?mtype=customer_management", "mainFrame")
  14. break;
  15. case "applicationsetting":
  16. window.open("/Administration.aspx?mtype=applicationsetting", "mainFrame")
  17. break;
  18. case "sub_administration":
  19. window.open("/Administration.aspx?mtype=sub_administration", "mainFrame")
  20. break;
  21. case "system_security":
  22. window.open("/Administration.aspx?mtype=system_security", "mainFrame")
  23. break;
  24. case "remittance":
  25. window.open("/Administration.aspx?mtype=remittance", "mainFrame")
  26. break;
  27. case "servicecharge_and_commission":
  28. window.open("/Administration.aspx?mtype=servicecharge_and_commission", "mainFrame")
  29. break;
  30. case "creditrisk_management":
  31. window.open("/Administration.aspx?mtype=creditrisk_management", "mainFrame")
  32. break;
  33. case "transaction":
  34. window.open("/Administration.aspx?mtype=transaction", "mainFrame")
  35. break;
  36. case "report":
  37. window.open("/Administration.aspx?mtype=report", "mainFrame")
  38. break;
  39. case "account":
  40. window.open("/Administration.aspx?mtype=account", "mainFrame")
  41. break;
  42. case "remittance_report":
  43. window.open("/Administration.aspx?mtype=remittance_report", "mainFrame")
  44. break;
  45. case "account_report":
  46. window.open("/Administration.aspx?mtype=account_report", "mainFrame")
  47. break;
  48. case "sub_account":
  49. window.open("/Administration.aspx?mtype=sub_account", "mainFrame")
  50. break;
  51. }
  52. }
  53. function LoadModuleAgentMenu(menuType) {
  54. return true;
  55. switch (menuType.toLowerCase()) {
  56. case "send_money":
  57. window.open("/AgentMenuTileView.aspx?mtype=send_money", "mainFrame");
  58. break;
  59. case "pay_money":
  60. window.open("/AgentMenuTileView.aspx?mtype=pay_money", "mainFrame");
  61. break;
  62. case "reports":
  63. window.open("/AgentMenuTileView.aspx?mtype=reports", "mainFrame");
  64. break;
  65. case "other_services":
  66. window.open("/AgentMenuTileView.aspx?mtype=other_services", "mainFrame");
  67. break;
  68. }
  69. }
  70. function ValidateExtension(id) {
  71. var allowedFiles = [".png", ".jpg", ".jpeg"];
  72. var fileUpload = document.getElementById(id);
  73. var regex = new RegExp("([a-zA-Z0-9\s_\\.\-:])+(" + allowedFiles.join('|') + ")$");
  74. if (!regex.test(fileUpload.value.toLowerCase())) {
  75. alert("Please upload files having extensions: " + allowedFiles.join(', ') + " only.");
  76. document.getElementById(id).value = '';
  77. return false;
  78. }
  79. return true;
  80. }
  81. function ValidateExtensionForOtherDoc(id) {
  82. var allowedFiles = [".png", ".jpg", ".jpeg", ".pdf"];
  83. var fileUpload = document.getElementById(id);
  84. var regex = new RegExp("([a-zA-Z0-9\s_\\.\-:])+(" + allowedFiles.join('|') + ")$");
  85. if (!regex.test(fileUpload.value.toLowerCase())) {
  86. alert("Please upload files having extensions: " + allowedFiles.join(', ') + " only.");
  87. document.getElementById(id).value = '';
  88. return false;
  89. }
  90. return true;
  91. }
  92. Date.prototype.toUSFormat = function () {
  93. var dd = this.getDate();
  94. if (dd < 10) dd = '0' + dd;
  95. var mm = this.getMonth() + 1;
  96. if (mm < 10) mm = '0' + mm;
  97. var yyyy = this.getFullYear();
  98. return String(mm + "\/" + dd + "\/" + yyyy)
  99. }
  100. function OpenInNewWindowModifyChrome(url, param) {
  101. if (param == undefined || param == "") {
  102. param = "width=600,height=400,resizable=1,status=1,toolbar=0,scrollbars=1,center=1";
  103. }
  104. return window.open(url, window.self, param);
  105. }
  106. function PopUpWindowWithCallBackBigSize(url, param) {
  107. if (param == undefined || param == "") {
  108. param = "dialogHeight:1000px;dialogWidth:1100px;dialogLeft:150;dialogTop:50;center:yes";
  109. }
  110. if (isChrome) {
  111. return window.open(url, "_blank", param);
  112. } else {
  113. return window.showModalDialog(url, window.self, param);
  114. }
  115. //return window.showModalDialog(url, window.self, param);
  116. }
  117. function RemoveComma(value) {
  118. return value.replace(/,/g, "");
  119. }
  120. function ConvertDate(dt, seprator) {
  121. var d = new Date(dt),
  122. month = '' + (d.getMonth() + 1),
  123. day = '' + d.getDate(),
  124. year = d.getFullYear();
  125. return [year, month, day].join(seprator);
  126. }
  127. function FilterString(value) {
  128. //alert(value);
  129. value = value.replace("NaN", "");
  130. return value.replace(/[^a-zA-Z0-9 .()]/g, "");
  131. }
  132. function bookmarksite() {
  133. var title = document.title, url = window.location.href;
  134. if (window.sidebar) // firefox
  135. window.sidebar.addPanel(title, url, "");
  136. else if (window.opera && window.print) { // opera
  137. var elem = document.createElement('a');
  138. elem.setAttribute('href', url);
  139. elem.setAttribute('title', title);
  140. elem.setAttribute('rel', 'sidebar');
  141. elem.click();
  142. }
  143. else if (document.all)// ie
  144. window.external.AddFavorite(url, title);
  145. }
  146. function EnableDisableBtn(id, boolDisabled) {
  147. try {
  148. var ctl = GetElement(id);
  149. ctl.disabled = boolDisabled;
  150. var cssClass = "button" + (boolDisabled ? "Disabled" : "");
  151. var thisClass = ctl.className;
  152. thisClass = thisClass.replace("buttonDisabled", "");
  153. thisClass = thisClass.replace("buttonEnabled", "");
  154. cssClass = cssClass + " " + thisClass;
  155. SetCSSByObj(ctl, cssClass);
  156. } catch (ex) { }
  157. }
  158. function LoadRegion(flag, divZip, divDistrict, region) {
  159. if (flag == 'o') { //o - for Other
  160. ShowElement(divZip);
  161. HideElement(divDistrict);
  162. GetElement(region).innerHTML = "State";
  163. return;
  164. }
  165. else if (flag == 'n') { //n - for Nepal
  166. ShowElement(divDistrict);
  167. HideElement(divZip);
  168. GetElement(region).innerHTML = "Zone";
  169. return;
  170. }
  171. }
  172. function MoveWindowToTop() {
  173. var target = window.parent.document.getElementById('Td1');
  174. target.scrollIntoView();
  175. }
  176. function ReadData(id, singleQuote, focusIfNull) {
  177. var obj = document.getElementById(id);
  178. if (obj) return (singleQuote ? "'" + obj.value + "'" : obj.value);
  179. return "null";
  180. }
  181. function IsCSVFile(fileName) {
  182. var file_parts = fileName.split(".");
  183. if (file_parts[file_parts.length - 1].toUpperCase() == "CSV")
  184. return true;
  185. return false;
  186. }
  187. function GetListBoxItems(id, selectedOnly) {
  188. var list = document.getElementById(id);
  189. var valueList = "";
  190. var cnt = list.options.length;
  191. var values = [];
  192. for (var i = 0; i < cnt; i++) {
  193. var item = list.options[i];
  194. if (item.selected || (!selectedOnly)) {
  195. values.push(item.value);
  196. }
  197. }
  198. return values;
  199. }
  200. function HideElement(id) {
  201. ObjHide(GetElement(id));
  202. }
  203. function ObjHide(obj) {
  204. try {
  205. obj.style.display = "none";
  206. } catch (ex) { }
  207. }
  208. function ShowElement(id) {
  209. ObjShow(GetElement(id));
  210. }
  211. function ShowElementNew(id) {
  212. ObjShowNew(GetElement(id));
  213. }
  214. function ObjShowNew(obj) {
  215. try {
  216. obj.style.display = "contents";
  217. } catch (ex) { }
  218. }
  219. function ObjShow(obj) {
  220. try {
  221. obj.style.display = "block";
  222. } catch (ex) { }
  223. }
  224. var guid = (function () {
  225. function s4() {
  226. return Math.floor((1 + Math.random()) * 0x10000)
  227. .toString(16)
  228. .substring(1);
  229. }
  230. return function () {
  231. return s4() + s4() + '' + s4() + '' + s4();
  232. };
  233. })();
  234. function OpenInNewWindow(url) {
  235. url = url + "&srcCode=" + guid;
  236. window.open(url, "", "width=825,height=500,resizable=1,status=1,toolbar=0,scrollbars=1,center=1");
  237. }
  238. function OpenInNewSmallWindow(url) {
  239. url = url + "&srcCode=" + guid;
  240. window.open(url, "", "width=430,height=300,resizable=1,status=1,toolbar=0,scrollbars=1,center=1");
  241. }
  242. function GetValue(id) {
  243. var obj = document.getElementById(id);
  244. if (obj == null || obj == undefined)
  245. return "";
  246. return obj.value;
  247. }
  248. function GetElement(id) {
  249. return document.getElementById(id);
  250. }
  251. function GetDateValue(id) {
  252. var value = GetValue(id);
  253. if (value == "")
  254. return value;
  255. var dateParts = value.split("/");
  256. if (dateParts.length < 3)
  257. return "";
  258. var y = dateParts[0].toString("0000");
  259. var m = dateParts[1].toString("00");
  260. var d = dateParts[2].toString("00");
  261. return y + "/" + m + '/' + d;
  262. }
  263. function GetDateValueNew(id) {
  264. var value = GetValue(id);
  265. if (value === "")
  266. return value;
  267. var dateParts = value.split("-");
  268. if (dateParts.length < 3)
  269. return "";
  270. var y = dateParts[0].toString("0000");
  271. var m = dateParts[1].toString("00");
  272. var d = dateParts[2].toString("00");
  273. return y + "/" + m + '/' + d;
  274. }
  275. function SelectOrClearByElement(elements, boolSelect) {
  276. for (var i = 0; i < elements.length; i++) {
  277. try {
  278. elements[i].checked = boolSelect;
  279. } catch (ex) {
  280. }
  281. }
  282. }
  283. function SelectOrClearById(cbContainerId, boolSelect) {
  284. var elements = GetElement(cbContainerId).getElementsByTagName("input");
  285. SelectOrClearByElement(elements, boolSelect);
  286. }
  287. function EnableOrDisableDdlByElement(elements, boolDisabled) {
  288. for (var i = 0; i < elements.length; i++) {
  289. try {
  290. elements[i].disabled = boolDisabled;
  291. } catch (ex) {
  292. }
  293. }
  294. }
  295. function EnableOrDisableDdlById(cbContainerId, boolDisabled) {
  296. var elements = GetElement(cbContainerId).getElementsByTagName("select");
  297. EnableOrDisableDdlByElement(elements, boolDisabled);
  298. }
  299. function PrintWindow() {
  300. window.parent.frames["frmame_main"].focus();
  301. window.parent.frames["frmame_main"].document.execCommand('print', false, null);
  302. return false;
  303. }
  304. function ReportPrint() {
  305. window.print();
  306. return false;
  307. }
  308. function DownloadReport(path) {
  309. url = path + "/Download.aspx?mode=report";
  310. OpenInNewWindow(url);
  311. }
  312. function HasValidExtension(fileName, ext) {
  313. var file_parts = fileName.split(".");
  314. if (file_parts[file_parts.length - 1].toUpperCase() == ext.toUpperCase())
  315. return true;
  316. return false;
  317. }
  318. function DownloadInNewWindow(url) {
  319. window.open(url, "", "width=825,height=500,resizable=1,status=1,toolbar=0,scrollbars=1,center=1");
  320. }
  321. function SelectFunctions(me, parent) {
  322. var elements = document.getElementsByName("functionId");
  323. var cssName = me.className;
  324. var cssLength = cssName.length;
  325. var newCss = "";
  326. var boolChecked = false;
  327. if (cssName.substr(cssLength - 8, cssLength) == "Selected") {
  328. newCss = cssName.substr(0, cssLength - 8);
  329. } else {
  330. newCss = cssName + "Selected";
  331. boolChecked = true;
  332. }
  333. var parentLength = parent.length;
  334. for (var i = 0; i < elements.length; i++) {
  335. if (!elements[i].disabled) {
  336. var value = elements[i].value;
  337. if (value.substr(0, parentLength) == parent) {
  338. elements[i].checked = boolChecked;
  339. }
  340. }
  341. }
  342. me.className = newCss;
  343. }
  344. function Redirect(url) {
  345. window.parent.location = url;
  346. }
  347. function RedirectLocal(url) {
  348. window.location = url;
  349. }
  350. function OpenDialog(url, height, width, left, top) {
  351. if (isChrome) {
  352. var param = "";
  353. if (param == undefined || param == "")
  354. param = "width=1000,height=500,resizable=1,status=1,toolbar=0,scrollbars=1,center=1";
  355. return window.open(url, "_blank", param);
  356. } else {
  357. return window.showModalDialog(url, window.self, "dialogHeight:" + height + "px;dialogWidth:" + width + "px;dialogLeft:" + left + "px;dialogTop:" + top + "px");
  358. }
  359. // return window.showModalDialog(url, window.self, "dialogHeight:" + height + "px;dialogWidth:" + width + "px;dialogLeft:" + left + "px;dialogTop:" + top + "px");
  360. }
  361. function CloseDialog(returnValue) {
  362. window.returnValue = returnValue;
  363. window.close();
  364. }
  365. function GoBack() {
  366. if (confirm("Are you sure to want to go back?")) {
  367. window.history.back(1);
  368. }
  369. }
  370. function OpenWindow(url) {
  371. var browser = navigator.appName;
  372. if (browser == "Microsoft Internet Explorer") {
  373. window.opener = self;
  374. }
  375. window.open(url, "", "width=900,height=750,toolbar=no,scrollbars=yes,location=no,resizable =yes");
  376. window.moveTo(0, 0);
  377. window.resizeTo(screen.width, screen.height - 100);
  378. self.close();
  379. }
  380. function PopUpWindow(url, param) {
  381. if (param == undefined || param == "") {
  382. param = "dialogHeight:500px;dialogWidth:600px;dialogLeft:300;dialogTop:100;center:yes";
  383. }
  384. if (isChrome) {
  385. window.open(url, "_blank", param);
  386. } else {
  387. return window.showModalDialog(url, window.self, param);
  388. }
  389. //return window.showModalDialog(url, window.self, param); //changed instead of showModalDialog()
  390. }
  391. function PopUpWithCallBack(url, param) {
  392. if (param == undefined || param == "") {
  393. param = "dialogHeight:400px;dialogWidth:500px;dialogLeft:300;dialogTop:100;center:yes";
  394. }
  395. if (isChrome) {
  396. window.open(url, "_blank", param);
  397. } else {
  398. window.showModalDialog(url, window.self, param);
  399. }
  400. //errorCode = window.showModalDialog(url, window.self, param);
  401. CallBack();
  402. }
  403. function OpenInNewWindow(url) {
  404. window.open(url, "_blank", "width=825,height=500,resizable=1,status=1,toolbar=0,scrollbars=1,center=1");
  405. }
  406. function PopUpWindowWithCallBack(url, param) {
  407. if (param == undefined || param == "") {
  408. param = "width=1000,height=500,resizable=1,status=1,toolbar=0,scrollbars=1,center=1";
  409. }
  410. if (isChrome) {
  411. return window.open(url, "_blank", param);
  412. } else {
  413. return window.showModalDialog(url, window.self, param);
  414. }
  415. //return window.showModalDialog(url, window.self, param);
  416. }
  417. function downloadInNewWindow(url) {
  418. window.open(url, "", "width=825,height=500,resizable=1,status=1,toolbar=0,scrollbars=1,center=1");
  419. }
  420. function FindPos(obj) {
  421. var curleft = curtop = 0;
  422. if (obj.offsetParent) {
  423. curleft = obj.offsetLeft
  424. curtop = obj.offsetTop
  425. while (obj = obj.offsetParent) {
  426. curleft += obj.offsetLeft
  427. curtop += obj.offsetTop
  428. }
  429. }
  430. return [curleft, curtop];
  431. }
  432. function numericOnly(obj, e, supportDecimal, doNotSupportNegative) {
  433. //var e = event || evt; // for trans-browser compatibility
  434. var evtobj = window.event ? event : e;
  435. if (evtobj.altKey || evtobj.ctrlKey)
  436. return true;
  437. var charCode = e.which || e.keyCode;
  438. if (doNotSupportNegative) {
  439. if (charCode == 189 || charCode == 109) {
  440. return false;
  441. }
  442. }
  443. if (charCode == 46 || charCode == 8 || charCode == 9 || charCode == 37 || charCode == 39 || charCode == 109)
  444. return true;
  445. var char = String.fromCharCode(charCode);
  446. //alert(charCode + " " + char);
  447. if (char == "." || char == "¾" || charCode == 110) {
  448. if (obj.value.indexOf(".") > -1)
  449. return false;
  450. else
  451. return true;
  452. }
  453. // if (isNaN(char))
  454. // return false;
  455. if ((char >= "0" && char <= "9") || (charCode >= 96 && charCode <= 105))
  456. return true;
  457. return false;
  458. }
  459. function TrackChanges(hddField) {
  460. GetElement(hddField).value = 'y';
  461. }
  462. function manageOnPaste(me) {
  463. return true;
  464. }
  465. function resetInput(obj, hint, type, isNum, allowBlank) {
  466. var val = parseFloat(obj.value);
  467. if (type == 1) {
  468. if (val == hint || (isNum && isNaN(obj.value))) { obj.value = ""; }
  469. }
  470. else {
  471. if (val.length == 0 || (isNum && isNaN(obj.value))) {
  472. if (allowBlank) {
  473. obj.value = "";
  474. } else {
  475. obj.value = hint;
  476. }
  477. }
  478. }
  479. }
  480. function ParseMessageToArray(mes) {
  481. var results = mes.split("-:::-");
  482. return results;
  483. }
  484. function GetIds(name) {
  485. var elements = document.getElementsByName(name);
  486. var list = "";
  487. for (var i = 0; i < elements.length; i++) {
  488. try {
  489. if (elements[i].checked) {
  490. list = list + (list != "" ? ", " : "") + elements[i].value;
  491. }
  492. }
  493. catch (ex) {
  494. return "";
  495. }
  496. }
  497. return list;
  498. }
  499. //Textbox with Comma Separation
  500. function CurrencyFormatted(amount) {
  501. var i = parseFloat(amount);
  502. if (isNaN(i)) { i = 0.00; }
  503. var minus = '';
  504. if (i < 0) { minus = '-'; }
  505. i = Math.abs(i);
  506. i = parseInt((i + .005) * 100);
  507. i = i / 100;
  508. s = new String(i);
  509. if (s.indexOf('.') < 0) { s += '.00'; }
  510. if (s.indexOf('.') == (s.length - 2)) { s += '0'; }
  511. s = minus + s;
  512. return s;
  513. }
  514. function CommaFormatted(amount) {
  515. var delimiter = ",";
  516. var a = amount.split('.', 2);
  517. var d = a[1];
  518. var i = parseInt(a[0]);
  519. if (isNaN(i)) { return ''; }
  520. var minus = '';
  521. if (i < 0) { minus = '-'; }
  522. i = Math.abs(i);
  523. var n = new String(i);
  524. var a = [];
  525. while (n.length > 3) {
  526. var nn = n.substr(n.length - 3);
  527. a.unshift(nn);
  528. n = n.substr(0, n.length - 3);
  529. }
  530. if (n.length > 0) { a.unshift(n); }
  531. n = a.join(delimiter);
  532. if (d.length < 1) { amount = n; }
  533. else { amount = n + '.' + d; }
  534. amount = minus + amount;
  535. return amount;
  536. }
  537. function UpdateComma(obj) {
  538. var s = new String();
  539. var amt = obj.value.replace(",", "");
  540. amt = amt.replace(",", "");
  541. amt = amt.replace(",", "");
  542. amt = amt.replace(",", "");
  543. //alert(amt);
  544. s = CurrencyFormatted(amt);
  545. s = CommaFormatted(s);
  546. obj.value = s;
  547. }
  548. function roundNumber(rnum, rlength) { // Arguments: number to round, number of decimal places
  549. var newnumber = Math.round(rnum * Math.pow(10, rlength)) / Math.pow(10, rlength);
  550. return parseFloat(newnumber); // Output the result to the form field (change for your purposes)
  551. }
  552. function roundNumberUp(rnum, rlength) {
  553. var ad = 5 / Math.pow(10, rlength + 1);
  554. return roundNumber(rnum + ad, rlength);
  555. }
  556. function roundNumberDown(rnum, rlength) {
  557. var ad = 5 / Math.pow(10, rlength + 1);
  558. return roundNumber(rnum - ad, rlength);
  559. }
  560. //End
  561. document.onkeydown = KeyDownHandler;
  562. document.onkeyup = KeyUpHandler;
  563. var CTRL = false;
  564. var SHIFT = false;
  565. var ALT = false;
  566. var CHAR_CODE = -1;
  567. function KeyDownHandler(e) {
  568. var x = '';
  569. if (document.all) {
  570. var evnt = window.event;
  571. x = evnt.keyCode;
  572. }
  573. else {
  574. x = e.keyCode;
  575. }
  576. DetectKeys(x, true);
  577. // Lock();
  578. MenuControl();
  579. }
  580. function KeyUpHandler(e) {
  581. var x = '';
  582. if (document.all) {
  583. var evnt = window.event;
  584. x = evnt.keyCode;
  585. }
  586. else {
  587. x = e.keyCode;
  588. }
  589. DetectKeys(x, false);
  590. // Lock();
  591. MenuControl();
  592. }
  593. function MenuControl() {
  594. }
  595. function DetectKeys(KeyCode, IsKeyDown) {
  596. if (KeyCode == '16') {
  597. SHIFT = IsKeyDown;
  598. CHAR_CODE = -1;
  599. }
  600. else if (KeyCode == '17') {
  601. CTRL = IsKeyDown;
  602. CHAR_CODE = -1;
  603. }
  604. else if (KeyCode == '18') {
  605. ALT = IsKeyDown;
  606. CHAR_CODE = -1;
  607. }
  608. else {
  609. if (IsKeyDown)
  610. CHAR_CODE = KeyCode;
  611. else
  612. CHAR_CODE = -1;
  613. }
  614. }
  615. function Lock() {
  616. if (ALT && CHAR_CODE == 76) {
  617. if (confirm("Are you sure you want to lock application?")) {
  618. // Session("url") = document.getElementById("frmame_main").contentWindow.location.href;
  619. var url = window.parent.document.getElementById("frmame_main").contentWindow.location.href;
  620. window.parent.location.replace('/Lock.aspx?url=' + url);
  621. }
  622. }
  623. }
  624. //START RATE MASKING
  625. function checkRateMasking(obj, beforeLength, afterLength) {
  626. if (isNaN(obj.value)) {
  627. alert("Please, Enter valid number !");
  628. setTimeout(function () { obj.focus(); }, 1);
  629. return 1;
  630. }
  631. if (obj.value.indexOf(".") >= 0) {
  632. var resStr = obj.value.split(".");
  633. if (beforeLength != "99" && obj.value != "0" && obj.value != "") {
  634. var bdValue = resStr[0];
  635. var bdValueLength = bdValue.length;
  636. if (parseFloat(obj.value) < 0)
  637. bdValueLength = bdValue.length - 1;
  638. if (bdValueLength > beforeLength) {
  639. if (parseInt(bdValueLength) > parseInt(beforeLength)) {
  640. alert("Error, Only " + beforeLength + " digit(s) are allowed before decimal !");
  641. setTimeout(function () { obj.focus(); }, 1);
  642. return 1;
  643. }
  644. }
  645. }
  646. if (afterLength != "99" && obj.value != "0" && obj.value != "") {
  647. if (resStr[1].length > afterLength) {
  648. if (resStr[1].length > afterLength) {
  649. alert("Error, Only " + afterLength + " digit(s) are allowed after decimal !");
  650. setTimeout(function () { obj.focus(); }, 1);
  651. return 1;
  652. }
  653. }
  654. }
  655. }
  656. else {
  657. if (beforeLength != "99" && obj.value != "0" && obj.value != "") {
  658. bdValue = obj.value;
  659. bdValueLength = bdValue.length;
  660. if (bdValue < 0)
  661. bdValueLength = bdValue.length - 1;
  662. if (parseInt(bdValueLength) > parseInt(beforeLength)) {
  663. alert("Error, Only " + beforeLength + " digit(s) are allowed before decimal !");
  664. setTimeout(function () { obj.focus(); }, 1);
  665. return 1;
  666. }
  667. }
  668. }
  669. return 0;
  670. }
  671. function CheckNumberWithMsg(obj) {
  672. if (isNaN(obj.value)) {
  673. alert("Input value = " + obj.value + "\n\nPlease enter valid number!");
  674. obj.value = 0;
  675. setTimeout(function () { obj.focus(); }, 1);
  676. }
  677. }
  678. function checkRateCapping2(obj, currentValue, min, max, value, id, errorImg) {
  679. if (isNaN(obj.value)) {
  680. alert("Please, Enter valid number !");
  681. setTimeout(function () { obj.focus(); }, 1);
  682. return 1;
  683. }
  684. value = roundNumber(value, 6);
  685. var msg = "";
  686. GetElement("status_" + id).innerHTML = "";
  687. EnableDisableBtn("btnUpdate_" + id, false);
  688. if (value > max) {
  689. msg = "Calculated value = " + value + "\n\nRate must lie between " + min + " and " + max;
  690. alert(msg);
  691. obj.value = currentValue;
  692. if (currentValue > max) {
  693. GetElement("status_" + id).innerHTML = "<img src=\"" + errorImg + "\" border=\"0\" onclick=\"alert('" + msg + "');\"/>";
  694. EnableDisableBtn("btnUpdate_" + id, true);
  695. }
  696. else if (currentValue < min) {
  697. GetElement("status_" + id).innerHTML = "<img src=\"" + errorImg + "\" border=\"0\" onclick=\"alert('" + msg + "');\"/>";
  698. EnableDisableBtn("btnUpdate_" + id, true);
  699. }
  700. else
  701. setTimeout(function () { obj.focus(); }, 1);
  702. return 1;
  703. }
  704. if (value < min) {
  705. msg = "Calculated value = " + value + "\n\nRate must lie between " + min + " and " + max;
  706. alert(msg);
  707. obj.value = currentValue;
  708. if (currentValue > max) {
  709. GetElement("status_" + id).innerHTML = "<img src=\"" + errorImg + "\" border=\"0\" onclick=\"alert('" + msg + "');\"/>";
  710. EnableDisableBtn("btnUpdate_" + id, true);
  711. }
  712. else if (currentValue < min) {
  713. GetElement("status_" + id).innerHTML = "<img src=\"" + errorImg + "\" border=\"0\" onclick=\"alert('" + msg + "');\"/>";
  714. EnableDisableBtn("btnUpdate_" + id, true);
  715. }
  716. else
  717. setTimeout(function () { obj.focus(); }, 1);
  718. return 1;
  719. }
  720. return 0;
  721. }
  722. function checkRateCapping(obj, currentValue, min, max, value) {
  723. if (isNaN(obj.value)) {
  724. alert("Please, Enter valid number !");
  725. setTimeout(function () { obj.focus(); }, 1);
  726. return 1;
  727. }
  728. value = roundNumber(value, 6);
  729. if (value > max) {
  730. alert("Calculated value = " + value + "\n\nRate must lie between " + min + " and " + max);
  731. if (currentValue > max)
  732. currentValue = 0;
  733. obj.value = currentValue;
  734. setTimeout(function () { obj.focus(); }, 1);
  735. return 1;
  736. }
  737. if (value < min) {
  738. alert("Calculated value = " + value + "\n\nRate must lie between " + min + " and " + max);
  739. if (currentValue < min)
  740. currentValue = 0;
  741. obj.value = currentValue;
  742. setTimeout(function () { obj.focus(); }, 1);
  743. return 1;
  744. }
  745. return 0;
  746. }
  747. function checkCrossRateCapping(obj, currentValue, cMin, cMax, pMin, pMax, crossRate, crossRateMaskAd) {
  748. if (isNaN(obj.value)) {
  749. alert("Please, Enter valid number !");
  750. setTimeout(function () { obj.focus(); }, 1);
  751. return 1;
  752. }
  753. var minCustomerRate = pMin / cMax;
  754. minCustomerRate = roundNumber(minCustomerRate, crossRateMaskAd);
  755. var maxCustomerRate = pMax / cMin;
  756. maxCustomerRate = roundNumber(maxCustomerRate, crossRateMaskAd);
  757. if (crossRate > maxCustomerRate) {
  758. alert("Input value = " + crossRate + "\n\nRate must lie between " + minCustomerRate + " and " + maxCustomerRate);
  759. setTimeout(function () { obj.focus(); }, 1);
  760. obj.value = currentValue;
  761. return 1;
  762. }
  763. else if (crossRate < minCustomerRate) {
  764. alert("Input value = " + crossRate + "\n\nRate must lie between " + minCustomerRate + " and " + maxCustomerRate);
  765. setTimeout(function () { obj.focus(); }, 1);
  766. obj.value = currentValue;
  767. return 1;
  768. }
  769. return 0;
  770. }
  771. function ParseResultJsPrint(errorCode, msg, id) {
  772. return errorCode + "-:::-" + msg + "-:::-" + id;
  773. }
  774. function cVal(data) {
  775. var res = parseFloat(data);
  776. if (isNaN(res)) res = 0;
  777. return res;
  778. }
  779. function hideMessageBox() {
  780. var rptCentraizeMassege = document.getElementById("rptCentraizeMassege");
  781. rptCentraizeMassege.innerHTML = "";
  782. rptCentraizeMassege.className = "";
  783. }
  784. function SetValueById(id, value, innerHTML) {
  785. SetValueByObj(GetElement(id), value, innerHTML);
  786. }
  787. function SetValueByObj(obj, value, innerHTML) {
  788. if (innerHTML) {
  789. obj.innerHTML = innerHTML;
  790. } else {
  791. obj.value = value;
  792. }
  793. }
  794. function SetValueIfNotById(id, value, innerHTML, notValue) {
  795. SetValueIfNotByObj(GetElement(id), value, innerHTML, notValue);
  796. }
  797. function SetValueIfNotByObj(obj, value, innerHTML, notValue) {
  798. value1 = GetValueByObj(obj, innerHTML);
  799. if (value1.toLowerCase() != notValue.toLowerCase()) {
  800. if (innerHTML) {
  801. obj.innerHTML = value;
  802. } else {
  803. obj.value = value;
  804. }
  805. }
  806. }
  807. function SetValueIfBlankById(id, value, innerHTML) {
  808. SetValueIfBlankByObj(GetElement(id), value, innerHTML);
  809. }
  810. function SetValueIfBlankByObj(obj, value, innerHTML) {
  811. var value1 = GetValueByObj(obj, innerHTML);
  812. if (value1 == "") {
  813. if (innerHTML) {
  814. obj.innerHTML = value;
  815. } else {
  816. obj.value = value;
  817. }
  818. }
  819. }
  820. function SetValueIfZeroById(id, value, innerHTML) {
  821. SetValueIfZeroByObj(GetElement(id), value, innerHTML);
  822. }
  823. function SetValueIfZeroByObj(obj, value, innerHTML) {
  824. var value1 = parseFloat(GetValueByObj(obj, innerHTML));
  825. if (value1 == 0) {
  826. if (innerHTML) {
  827. obj.innerHTML = value;
  828. } else {
  829. obj.value = value;
  830. }
  831. }
  832. }
  833. function SetCSSById(id, css) {
  834. SetCSSByObj(GetElement(id), css);
  835. }
  836. function SetCSSByObj(obj, css) {
  837. obj.className = css;
  838. }
  839. function CheckNumber(obj) {
  840. obj.value = cVal(obj.value);
  841. }
  842. function IntegerOnly(obj) {
  843. if (isNaN(obj.value)) {
  844. obj.value = "";
  845. return;
  846. }
  847. if (obj.value.indexOf(".") > -1) {
  848. obj.value = "";
  849. return;
  850. }
  851. }
  852. function FloatOnly(obj) {
  853. if (isNaN(obj.value)) {
  854. obj.value = "";
  855. return;
  856. }
  857. }
  858. //END MASKING VALIDATION
  859. function setCookie(c_name, value, exdays) {
  860. var exdate = new Date();
  861. exdate.setDate(exdate.getDate() + exdays);
  862. var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
  863. document.cookie = c_name + "=" + c_value;
  864. }
  865. function getCookie(c_name) {
  866. var i, x, y, ARRcookies = document.cookie.split(";");
  867. for (i = 0; i < ARRcookies.length; i++) {
  868. x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
  869. y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
  870. x = x.replace(/^\s+|\s+$/g, "");
  871. if (x == c_name) {
  872. return unescape(y);
  873. }
  874. }
  875. return "";
  876. }
  877. //Fix Decimal and Rounding
  878. function FixDecimalWithRound(num, afterDecimalCount) {
  879. return num.toFixed(afterDecimalCount).replace(/\.?0+$/, "");
  880. }
  881. function SetColorById(id, value) {
  882. if (value < 0)
  883. GetElement(id).setAttribute('style', 'color: red !important;');
  884. else
  885. GetElement(id).setAttribute('style', 'color: green !important;');
  886. }
  887. function datediff(fromDate, interval) {
  888. /*
  889. * DateFormat month/day/year hh:mm:ss
  890. * ex.
  891. * datediff('01/01/2011 12:00:00','01/01/2011 13:30:00','seconds');
  892. */
  893. var second = 1000, minute = second * 60, hour = minute * 60, day = hour * 24, week = day * 7;
  894. var currentDate = new Date()
  895. fromDate = new Date(fromDate);
  896. toDate = new Date(currentDate);
  897. var timediff = toDate - fromDate;
  898. if (isNaN(timediff)) return NaN;
  899. switch (interval) {
  900. case "years": return toDate.getFullYear() - fromDate.getFullYear();
  901. case "months": return (
  902. (toDate.getFullYear() * 12 + toDate.getMonth())
  903. -
  904. (fromDate.getFullYear() * 12 + fromDate.getMonth())
  905. );
  906. case "weeks": return Math.floor(timediff / week);
  907. case "days": return Math.floor(timediff / day);
  908. case "hours": return Math.floor(timediff / hour);
  909. case "minutes": return Math.floor(timediff / minute);
  910. case "seconds": return Math.floor(timediff / second);
  911. default: return undefined;
  912. }
  913. }
  914. function PrintMessage(msg, errorCode) {
  915. window.parent.SetMessageBox(msg, errorCode);
  916. }
  917. function CheckForSpecialCharacter(nField, fieldName) {
  918. var userInput = nField.value;
  919. if (userInput == "" || userInput == undefined) {
  920. return;
  921. }
  922. if (/^[a-zA-Z0-9- ./\\()-]*$/.test(userInput) == false) {
  923. alert('Special Character(e.g. !@#$%^&*) are not allowed in field : ' + fieldName);
  924. setTimeout(function () { nField.focus(); }, 1);
  925. }
  926. }
  927. function CheckForMobileNumber(nField, fieldName) {
  928. var userInput = nField.value;
  929. if (userInput == "" || userInput == undefined) {
  930. return;
  931. }
  932. if (/^[0-9- ./\\()]*$/.test(userInput) == false) {
  933. alert('Special Character(e.g. !@#$%^&*) are not allowed in field : ' + fieldName);
  934. setTimeout(function () { nField.focus(); }, 1);
  935. }
  936. }
  937. function CheckAlfabetOnly(nField, fieldName) {
  938. var userInput = nField.value;
  939. if (userInput == "" || userInput == undefined) {
  940. return;
  941. }
  942. if (/^[a-zA-Z ]*$/.test(userInput) == false) {
  943. alert('Only Character are allowed in field : ' + fieldName);
  944. setTimeout(function () { nField.focus(); }, 1);
  945. }
  946. }
  947. function CheckAddressValidation(nField, fieldName) {
  948. var userInput = nField.value;
  949. if (userInput == "" || userInput == undefined) {
  950. return;
  951. }
  952. if (/^[a-zA-Z .,/\()]*$/.test(userInput) == false) {
  953. alert('Only Character are allowed in field : ' + fieldName);
  954. setTimeout(function () { nField.focus(); }, 1);
  955. }
  956. }
  957. function RemoveElement(id) {
  958. var el = document.getElementById(id);
  959. if (el)
  960. document.body.removeChild(el);
  961. }
  962. function RemoveProcessDiv() {
  963. var id = "divProcess";
  964. RemoveElement(id);
  965. }
  966. function RemoveProcessDivWithMsg(msg) {
  967. var id = "divProcess";
  968. RemoveElement(id);
  969. alert(msg);
  970. }
  971. function Process() {
  972. var id = "divProcess";
  973. RemoveProcessDiv();
  974. var newdiv = document.createElement('div');
  975. newdiv.setAttribute('id', id);
  976. newdiv.style.width = "100%";
  977. var height = document.body.scrollHeight;
  978. if (height <= 826)
  979. height = '826';
  980. var html = "<center>";
  981. html += "<div class=\"still-bg\" id=\"progress\" style=\"height:" + height + "px;\">";
  982. html += "<div class=\"inner-bg\">";
  983. html += "<h3 style=\"color:white;\">Processing... Please wait.</h3>";
  984. html += "</div>";
  985. html += "</div>";
  986. html += "</center>";
  987. //alert(newdiv.innerHTML);
  988. newdiv.innerHTML = html;
  989. document.body.appendChild(newdiv);
  990. return true;
  991. }
  992. function ProcessWithConfirm(msg) {
  993. if (msg == undefined || msg == null) msg = "Are you sure to approve SELECTED transaction?";
  994. if (confirm(msg)) {
  995. return Process();
  996. }
  997. return false;
  998. }
  999. function SpecialCharToLineBreak(val) {
  1000. var sep = "-:::-";
  1001. var list = val.split(sep);
  1002. return list.join("\n");
  1003. }
  1004. function onlyAlphabets(e, t) {
  1005. try {
  1006. if (window.event) {
  1007. var charCode = window.event.keyCode;
  1008. }
  1009. else if (e) {
  1010. var charCode = e.which;
  1011. }
  1012. else { return true; }
  1013. if ((charCode > 64 && charCode < 91) || (charCode > 96 && charCode < 123) || charCode == 8 || charCode == 32 || charCode == 9 || charCode == 0)
  1014. return true;
  1015. else
  1016. return false;
  1017. }
  1018. catch (err) {
  1019. alert(err.Description);
  1020. }
  1021. }
  1022. function MakeNumericContactNoIdNo(obj, e) {
  1023. var evtobj = window.event ? event : e;
  1024. if (evtobj.altKey || evtobj.ctrlKey)
  1025. return true;
  1026. var charCode = e.which || e.keyCode;
  1027. if (charCode == 46 || charCode == 8 || charCode == 9 || charCode == 37 || charCode == 39 || charCode == 109 || charCode == 189 || charCode == 111 || charCode == 109)
  1028. return true;
  1029. var char = String.fromCharCode(charCode);
  1030. if (!isNaN(char))
  1031. return true;
  1032. if ((char >= "0" && char <= "9") || (charCode >= 96 && charCode <= 105 || charCode == 173 || charCode == 191 || charCode == 189 || charCode == 111 || charCode == 109))
  1033. return true;
  1034. return false;
  1035. }
  1036. function isInt(value) {
  1037. if (isNaN(value)) {
  1038. return false;
  1039. }
  1040. var x = parseFloat(value);
  1041. return (x | 0) === x;
  1042. }
  1043. function ContactNoValidation(obj) {
  1044. var rIdNo = obj.value;
  1045. var isIntegerVal = isInt(rIdNo);
  1046. if (isIntegerVal == true) {
  1047. var rIdN = parseInt(rIdNo);
  1048. if (rIdN == 0) {
  1049. rIdNo = rIdN;
  1050. }
  1051. }
  1052. if (rIdNo === 0 || rIdNo === "0" || rIdNo === "00" || rIdNo === "1234" || rIdNo.length < 6 || rIdNo.length > 10) {
  1053. alert("Invalid Input.");
  1054. obj.value = "";
  1055. obj.focus();
  1056. return false;
  1057. }
  1058. return true;
  1059. }
  1060. function IdNoValidation(obj) {
  1061. var rIdNo = obj.value;
  1062. var isIntegerVal = isInt(rIdNo);
  1063. if (isIntegerVal == true) {
  1064. var rIdN = parseInt(rIdNo);
  1065. if (rIdN == 0) {
  1066. rIdNo = rIdN;
  1067. }
  1068. }
  1069. if (rIdNo === 0 || rIdNo === "0" || rIdNo === "1234") {
  1070. alert("Invalid Input.");
  1071. obj.value = "";
  1072. obj.focus();
  1073. return false;
  1074. }
  1075. return true;
  1076. }
  1077. function OpenInNewWindowWithCallBack(url, param, callback) {
  1078. if (param == undefined || param == "")
  1079. param = "width=825,height=500,resizable=1,status=1,toolbar=0,scrollbars=1,center=1";
  1080. var res = window.open(url, "", param);
  1081. if (typeof (callback) == "function") {
  1082. try {
  1083. res.attachEvent("onbeforeunload", callback);
  1084. }
  1085. catch (err) {
  1086. res.onbeforeunload = callback;
  1087. }
  1088. }
  1089. }
  1090. // Supports alphabets and numbers no special characters except underscore('_') min 3 and max 20 characters.
  1091. var validchars = /^[A-Za-z0-9\/\\ -]{1,20}$/;
  1092. function checkIfValidChars(strValue) {
  1093. try {
  1094. //1) All alphanumeric characters should be accepted {A to Z, a to z, 0 to 9 and Special character - / \
  1095. if (!validchars.test(strValue)) {
  1096. alert("Cheque number you provided is invalid.");
  1097. return false;
  1098. }
  1099. }
  1100. catch (err) {
  1101. alert(err);
  1102. }
  1103. return true;
  1104. }
  1105. function checkIfAllCharIsSame(strValue) {
  1106. try {
  1107. // 2) Should not allow all characters or all zero as cheque number ( AAAAAA, BBBBBBB, aaaaaa, bbbbbb, 00000000)
  1108. if (strValue.length > 1) {
  1109. var charToCompare = strValue[0];
  1110. var isAllCharSame = true;
  1111. for (var i = 0; i < strValue.length; i++) {
  1112. if (charToCompare != strValue[i]) {
  1113. isAllCharSame = false;
  1114. break;
  1115. }
  1116. }
  1117. if (isAllCharSame) {
  1118. alert("Cheque number you provided is invalid.");
  1119. return false;
  1120. }
  1121. }
  1122. }
  1123. catch (err) {
  1124. alert(err);
  1125. }
  1126. return true;
  1127. }
  1128. function checkIfFistCharIsValid(strValue) {
  1129. try {
  1130. //3) Cheque number cannot be started with - / \
  1131. if (strValue == "-" || strValue == "/" || strValue == "\\") {
  1132. alert("Cheque number cannot started with this value [-/\\].");
  1133. return false;
  1134. }
  1135. }
  1136. catch (err) {
  1137. alert(err);
  1138. }
  1139. return true;
  1140. }
  1141. function checkIfCharsRepeated(strValue) {
  1142. try {
  1143. // Cheque number cannot have values in repetition followed by ( -- // \\ -/ /- -\ \- /\ \/ )
  1144. if (strValue.length > 1) {
  1145. var charToCompare = "-- // \\\\ -/ /- -\\ \\- /\\ \\/".split(" ");
  1146. var isCharRepeated = false;
  1147. for (var i = 0; i < charToCompare.length && !isCharRepeated; i++) {
  1148. for (var j = 0; j < strValue.length - 1; j++) {
  1149. // abc\/f-
  1150. if (charToCompare[i] == strValue.substring(j, j + 2)) {
  1151. isCharRepeated = true;
  1152. break;
  1153. }
  1154. }
  1155. }
  1156. if (isCharRepeated) {
  1157. alert("Cheque number you provided is invalid.");
  1158. return false;
  1159. }
  1160. }
  1161. }
  1162. catch (err) {
  1163. alert(err);
  1164. }
  1165. return true;
  1166. }
  1167. function ValidRequiredField(RequiredField) {
  1168. var Isvalid = true;
  1169. var OtherPersonFld = new Array;
  1170. var fld = RequiredField.split(',');
  1171. for (n = 0; n < fld.length - 1; n++) {
  1172. OtherPersonFld[n] = fld[n];
  1173. }
  1174. for (i = 0; i < OtherPersonFld.length; i++) {
  1175. GetElement(OtherPersonFld[i]).style.background = "#FFFFFF";
  1176. var a = GetElement(OtherPersonFld[i]).value;
  1177. if (GetElement(OtherPersonFld[i]).value == "") {
  1178. GetElement(OtherPersonFld[i]).style.background = "#FFCCD2";
  1179. Isvalid = false;
  1180. }
  1181. }
  1182. if (Isvalid == false) {
  1183. alert("Required Field(s)\n _____________________________ \n The red fields are required!")
  1184. }
  1185. return Isvalid;
  1186. }
  1187. //END MASKING VALIDATION
  1188. function ValidRequiredFieldAC(RequiredField) {
  1189. var Isvalid = true;
  1190. var OtherPersonFld = new Array;
  1191. var fld = RequiredField.split(',');
  1192. for (n = 0; n < fld.length - 1; n++) {
  1193. OtherPersonFld[n] = fld[n];
  1194. }
  1195. for (i = 0; i < OtherPersonFld.length; i++) {
  1196. GetElement(OtherPersonFld[i]).style.background = "#FFFFFF";
  1197. if (GetElement(OtherPersonFld[i]).value == "") {
  1198. GetElement(OtherPersonFld[i]).style.background = "#FFCCD2";
  1199. Isvalid = false;
  1200. }
  1201. }
  1202. if (Isvalid == false) {
  1203. alert("Required Field(s)\n _____________________________ \n The red fields are required!")
  1204. }
  1205. return Isvalid;
  1206. }
  1207. //function DateValidation() {
  1208. // var pattern = "/^(19[0-9][0-9]|20[0-4][0-9]|3050)[/](0?[1-9]|1[0-2])[/](0?[1-9]|[12][0-9]|3[02])$/";
  1209. // var date = .getElementsByClassName('.hasDatepicker');
  1210. // if ((date.test(pattern))) {
  1211. // alert("Date " + date);
  1212. // }
  1213. //}