Advertisement
Guest User

Untitled

a guest
Nov 15th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.75 KB | None | 0 0
  1. // This function is to check whether there are duplicates files when user uploads into the system and also make sure that only certain file type is accepted
  2. function checkFileDuplicates(e) {
  3.  
  4. var file_list = e.target.files;
  5. var photoFile = document.getElementById('photofile').value.substring(document.getElementById('photofile').value.lastIndexOf('\\') + 1);
  6. var passportFile = document.getElementById('passportfile').value.substring(document.getElementById('passportfile').value.lastIndexOf('\\') + 1);
  7.  
  8. var arrFileTypeArray = [photoFile, passportFile]
  9. var arrDuplicateFlag = [0, 0];
  10. var isFileDuplicate = false;
  11. var isFileCondition = false;
  12.  
  13. // Loop through the array to check for duplicates
  14. for (i = 0; i < arrFileTypeArray.length; i++) {
  15. for (y = 0; y < arrFileTypeArray.length; y++) {
  16. // If file names match, are not empty strings and not at the same index
  17. if (arrFileTypeArray[i] == arrFileTypeArray[y] && arrFileTypeArray[i].length > 0 && arrFileTypeArray[y].length > 0 && i != y) {
  18. // Set file name duplicate flag
  19. isFileDuplicate = true;
  20. arrFileTypeArray[y].value = null;
  21. }
  22. }
  23. }
  24.  
  25.  
  26. // Display appropriate dialog box message to the user
  27. for (var i = 0, file; file = file_list[i]; i++) {
  28. var sFileName = file.name;
  29. // To retrieve the file extension
  30. var sFileExtension = sFileName.split('.')[sFileName.split('.').length - 1].toLowerCase();
  31. var iFileSize = file.size;
  32. // To find out the size of the file
  33. var iConvert = (file.size / 204800).toFixed(2);
  34.  
  35. // Make sure only allow certain extension
  36. if (!(sFileExtension === "pdf" || sFileExtension === "doc" || sFileExtension === "docx" || sFileExtension === "zip" || sFileExtension === "rar" || sFileExtension === "jpg") || sFileExtension === "gif" || iFileSize > 204800) {
  37. txt = "Your upload file type : " + sFileExtension;
  38. txt += " and size: " + iConvert + " MB \n\n";
  39. txt += "Make sure your file format is .jpg,.gif,.rar,.doc,or .pdf and file size is less than 100Kb.\n";
  40. txt += "Please select a new valid file to upload.";
  41. isFileCondition = true;
  42.  
  43. }
  44.  
  45.  
  46.  
  47. }
  48.  
  49.  
  50. // Display the appropriate message
  51. if (isFileCondition)
  52. alert(txt);
  53. else if (isFileDuplicate)
  54. alert("Cannot upload duplicate file for same user. Please try again.");
  55.  
  56. }
  57.  
  58.  
  59.  
  60.  
  61. // Simple Form Validation to make sure if certain field is entered
  62. function validateForm() {
  63. // Retrieve the value from respective input field.
  64. var studentname = $('#StudentName').val();
  65. var txtr = $('#reason').val();
  66.  
  67. if (studentname == 'No' && txtr == '') {
  68. return false;
  69. } else return true;
  70.  
  71. }
  72.  
  73. // Function to clear all input field and display the effect
  74. function _clear() {
  75.  
  76. $(function() {
  77. $("#submission").dialog({
  78. modal: true,
  79. buttons: {
  80. Ok: function() {
  81. $(this).dialog("close");
  82. },
  83. },
  84. effect: "slideDown",
  85. duration: 100000
  86. });
  87. });
  88. }
  89.  
  90. // Simple page redirection using JavaScript
  91.  
  92. function redirectToIndex() {
  93. // Display the message real time to the user
  94. document.getElementById('delayMsg').innerHTML = 'Please wait you\'ll be redirected after <span id="countDown">5</span> seconds....';
  95. var count = 5;
  96. var timer = setInterval(function() {
  97. count--;
  98. document.getElementById('countDown').innerHTML = count;
  99. if (count === 0) {
  100. window.location = '/Index/';
  101. clearInterval(timer);
  102. }
  103. }, 1000);
  104. }
  105.  
  106. // Simple error message displays if input field is empty
  107. $('#name').keyup(function() {
  108. if (this.value == '')
  109. $('#err_msg').show();
  110. else
  111. $('#err_msg').hide();
  112. });
  113.  
  114.  
  115. // The following function is to calculate total amount user need to pay by using JavaScript to display the appropriate fee.
  116. // Total amount will also be validate in the server side to ensure no manipulation of fee through client and extra safety measures.
  117. function calculateTotalAmount() {
  118. var totalStudents = @Model.Students.Count;
  119. var totalAmount = 0;
  120.  
  121. // Loop to find the number of students which selected "Today" options or other options and display the final amount
  122. for (i = 0; i < totalStudents; i++) {
  123. if ($('input[name="Students[' + i + '].Apply"]:checked').val() == "Today") {
  124. var amount = parseInt(document.getElementById("totalcert" + i).value) * 150;
  125. totalAmount += amount;
  126. document.getElementById('amount' + i).innerHTML = amount;
  127.  
  128. } else {
  129. var amount = parseInt(document.getElementById("totalcert" + i).value) * 100;
  130. totalAmount += amount;
  131. document.getElementById('amount' + i).innerHTML = amount;
  132.  
  133. }
  134.  
  135. }
  136.  
  137. // The total amount display to the user
  138. document.getElementById('totalamount').innerHTML = '<b> ' + totalAmount + '</b>';
  139.  
  140. }
  141.  
  142.  
  143. // The following function is to dynamically generate the table form via client side to the user based on the number of applicants selected
  144. function generateApplicantTable() {
  145. $('.buttons').css('display', 'block');
  146.  
  147. // Make sure that the div is empty everytime the user select the number of applicants
  148. $('#dynamic_table').empty();
  149.  
  150.  
  151. var x = $('#NumberOfApplicants').val();
  152. var c = $('#NumberOfColumns').val();
  153.  
  154. // Create 2 variable to store the html codes
  155. var data = '';
  156. var complete = '';
  157. var y = 1;
  158. for (i = 0; i < x; i++) {
  159.  
  160.  
  161. data =
  162. '<tr><td style="text-align:center">' +
  163. '<b>' + y + '</b>' +
  164. '<td>' +
  165.  
  166. '<input id="Name' + y + '" name="Applicant[' + i + '].Name" style="height: 30px; font-size: 14px !important" type="text" class="form-control Applicant' +
  167. y +
  168. ' keyup"/>' +
  169. '<span style="color:#f90500 !important; display: none" id="req_percentage" class="req_title' + y +
  170. '">The Applicant Title is required.</span>' +
  171. '<span style="color:#f90500 !important; display: none" id="req_percentage" class="req_name' +
  172.  
  173. y +
  174. '">The Applicant Full Name is required.</span>' +
  175. '<span style="color:#f90500 !important; display: none" id="req_percentage" class="req_name2' +
  176.  
  177. y +
  178. '">This Applicant exist.</span>' +
  179. '</td>' +
  180. '<td>' +
  181. '<select onchange="yesnoCheck(this);" id="Rank' + y + '" name="Applicant[' + i + '].Rank" class="form-control Applicant' + y + '" style=" height: 30px; font-size: 14px;">' +
  182. '<option value="-- Please Select --">-- Please Select --</option>' +
  183. '<option>MASTER</option> ' +
  184. '<option>STUDENT</option> ' +
  185.  
  186. '<option>OTHER</option>' +
  187. '</select>' +
  188. '<div id="ifYes' + y + '" style="display: none;">' +
  189. '<input id="RankOther' + y + '" name="Applicant[' + i + '].RankOther" style="height: 30px; font-size: 14px !important" type="text" class="form-control Applicant' +
  190. y +
  191. ' keyup"/></div>' +
  192. '<span style="color:#f90500 !important; display: none" id="req_percentage" class="req_rank' +
  193. y +
  194. '">Rank is required.</span>' +
  195. '<span style="color:#f90500 !important; display: none" id="req_percentage" class="req_rank2' +
  196. y +
  197. '">Rank is required.</span>' +
  198. '<td>' +
  199. '<select id="Nationality' +
  200. y +
  201. '" name="Applicant[' + i + '].Nationality" class="form-control Applicant' +
  202. y +
  203. '" style="height: 30px; font-size: 14px;">' +
  204. '<option value="-- Please Select --">-- Please Select --</option>' +
  205. '<option>ALBANIA</option>' +
  206. '<option>AFGHANISTAN</option>' +
  207. '<option selected="selected">ALBANIA</option>' +
  208. '<option>ALGERIA</option>' +
  209. '<option>AMERICAN SAMOA</option>' +
  210. '<option>ANDORRA</option>' +
  211. '<option>ANGOLA</option>' +
  212. '<option>ANGUILLA</option>' +
  213. '<option>ANTARCTICA</option>' +
  214. '<option>ANTIGUA AND BARBUDA</option>' +
  215. '<option>ARGENTINA</option>' +
  216. '<option>ARMENIA</option>' +
  217. '<option>ARUBA</option>' +
  218. '<option>AUSTRALIA</option>' +
  219. '<option>AUSTRIA</option>' +
  220. '<option>AZERBAIJAN</option>' +
  221. '<option>BAHAMAS</option>' +
  222. '<option>BAHRAIN</option>' +
  223. '<option>BANGLADESH</option>' +
  224. '<option>BARBADOS</option>' +
  225. '<option>BELARUS</option>' +
  226. '<option>BELGIUM</option>' +
  227. '<option>BELIZE</option>' +
  228. '<option>BENIN</option>' +
  229. '<option>BERMUDA</option>' +
  230. '<option>BHUTAN</option>' +
  231. '<option>BOLIVIA</option>' +
  232. '<option>BOSNIA AND HERZEGOVINA</option>' +
  233. '<option>BOTSWANA</option>' +
  234. '<option>BOUVET ISLAND</option>' +
  235. '<option>BRAZIL</option>' +
  236. '<option>BRITISH INDIAN OCEAN TERRITORY</option>' +
  237. '<option>BRUNEI DARUSSALAM</option>' +
  238. '<option>BULGARIA</option>' +
  239. '<option>BURKINA FASO</option>' +
  240. '<option>BURUNDI</option>' +
  241. '<option>CAMBODIA</option>' +
  242. '<option>CAMEROON</option>' +
  243. '<option>CANADA</option>' +
  244. '<option>CAPE VERDE</option>' +
  245. '<option>CAYMAN ISLANDS</option>' +
  246. '<option>CENTRAL AFRICAN REPUBLIC</option>' +
  247. '<option>CHAD</option>' +
  248. '<option>CHILE</option>' +
  249. '<option>CHINA</option>' +
  250. '<option>CHRISTMAS ISLAND</option>' +
  251. '<option>COCOS (KEELING) ISLANDS</option>' +
  252. '<option>COLOMBIA</option>' +
  253. '<option>COMOROS</option>' +
  254. '<option>CONGO</option>' +
  255. '<option>CONGO, THE DEMOCRATIC REPUBLIC OF THE</option>' +
  256. '<option>COOK ISLANDS</option>' +
  257. '<option>COSTA RICA</option>' +
  258. '<option>COTE D&#x27;IVOIRE</option>' +
  259. '<option>CROATIA</option>' +
  260. '<option>CUBA</option>' +
  261. '<option>CYPRUS</option>' +
  262. '<option>CZECH REPUBLIC</option>' +
  263. '<option>DENMARK</option>' +
  264. '<option>DJIBOUTI</option>' +
  265. '<option>DOMINICA</option>' +
  266. '<option>DOMINICAN REPUBLIC</option>' +
  267. '<option>ECUADOR</option>' +
  268. '<option>EGYPT</option>' +
  269. '<option>EL SALVADOR</option>' +
  270. '<option>EQUATORIAL GUINEA</option>' +
  271. '<option>ERITREA</option>' +
  272. '<option>ESTONIA</option>' +
  273. '<option>ETHIOPIA</option>' +
  274. '<option>FALKLAND ISLANDS (MALVINAS)</option>' +
  275. '<option>FAROE ISLANDS</option>' +
  276. '<option>FIJI</option>' +
  277. '<option>FINLAND</option>' +
  278. '<option>FRANCE</option>' +
  279. '<option>FRENCH GUIANA</option>' +
  280. '<option>FRENCH POLYNESIA</option>' +
  281. '<option>FRENCH SOUTHERN TERRITORIES</option>' +
  282. '<option>GABON</option>' +
  283. '<option>GAMBIA</option>' +
  284. '<option>GEORGIA</option>' +
  285. '<option>GERMANY</option>' +
  286. '<option>GHANA</option>' +
  287. '<option>GIBRALTAR</option>' +
  288. '<option>GREECE</option>' +
  289. '<option>GREENLAND</option>' +
  290. '<option>GRENADA</option>' +
  291. '<option>GUADELOUPE</option>' +
  292. '<option>GUAM</option>' +
  293. '<option>GUATEMALA</option>' +
  294. '<option>GUINEA</option>' +
  295. '<option>GUINEA-BISSAU</option>' +
  296. '<option>GUYANA</option>' +
  297. '<option>HAITI</option>' +
  298. '<option>HEARD ISLAND AND MCDONALD ISLANDS</option>' +
  299. '<option>HOLY SEE (VATICAN CITY STATE)</option>' +
  300. '<option>HONDURAS</option>' +
  301. '<option>HONG KONG</option>' +
  302. '<option>HUNGARY</option>' +
  303. '<option>ICELAND</option>' +
  304. '<option>INDIA</option>' +
  305. '<option>INDONESIA</option>' +
  306. '<option>IRAN, ISLAMIC REPUBLIC OF</option>' +
  307. '<option>IRAQ</option>' +
  308. '<option>IRELAND</option>' +
  309. '<option>ISRAEL</option>' +
  310. '<option>ITALY</option>' +
  311. '<option>JAMAICA</option>' +
  312. '<option>JAPAN</option>' +
  313. '<option>JORDAN</option>' +
  314. '<option>KAZAKHSTAN</option>' +
  315. '<option>KENYA</option>' +
  316. '<option>KIRIBATI</option>' +
  317. '<option>KOREA, DEMOCRATIC PEOPLE&#x27;S REPUBLIC OF</option>' +
  318. '<option>KOREA, REPUBLIC OF</option>' +
  319. '<option>KUWAIT</option>' +
  320. '<option>KYRGYZSTAN</option>' +
  321. '<option>LAO PEOPLE&#x27;S DEMOCRATIC REPUBLIC</option>' +
  322. '<option>LATVIA</option>' +
  323. '<option>LEBANON</option>' +
  324. '<option>LESOTHO</option>' +
  325. '<option>LIBERIA</option>' +
  326. '<option>LIBYAN ARAB JAMAHIRIYA</option>' +
  327. '<option>LIECHTENSTEIN</option>' +
  328. '<option>LITHUANIA</option>' +
  329. '<option>LUXEMBOURG</option>' +
  330. '<option>MACAO</option>' +
  331. '<option>MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF</option>' +
  332. '<option>MADAGASCAR</option>' +
  333. '<option>MALAWI</option>' +
  334. '<option>MALAYSIA</option>' +
  335. '<option>MALDIVES</option>' +
  336. '<option>MALI</option>' +
  337. '<option>MALTA</option>' +
  338. '<option>MARSHALL ISLANDS</option>' +
  339. '<option>MARTINIQUE</option>' +
  340. '<option>MAURITANIA</option>' +
  341. '<option>MAURITIUS</option>' +
  342. '<option>MAYOTTE</option>' +
  343. '<option>MEXICO</option>' +
  344. '<option>MICRONESIA, FEDERATED STATES OF</option>' +
  345. '<option>MOLDOVA, REPUBLIC OF</option>' +
  346. '<option>MONACO</option>' +
  347. '<option>MONGOLIA</option>' +
  348. '<option>MONTSERRAT</option>' +
  349. '<option>MOROCCO</option>' +
  350. '<option>MOZAMBIQUE</option>' +
  351. '<option>MYANMAR</option>' +
  352. '<option>NAMIBIA</option>' +
  353. '<option>NAURU</option>' +
  354. '<option>NEPAL</option>' +
  355. '<option>NETHERLANDS</option>' +
  356. '<option>NETHERLANDS ANTILLES</option>' +
  357. '<option>NEW CALEDONIA</option>' +
  358. '<option>NEW ZEALAND</option>' +
  359. '<option>NICARAGUA</option>' +
  360. '<option>NIGER</option>' +
  361. '<option>NIGERIA</option>' +
  362. '<option>NIUE</option>' +
  363. '<option>NORFOLK ISLAND</option>' +
  364. '<option>NORTHERN MARIANA ISLANDS</option>' +
  365. '<option>NORWAY</option>' +
  366. '<option>OMAN</option>' +
  367. '<option>PAKISTAN</option>' +
  368. '<option>PALAU</option>' +
  369. '<option>PALESTINIAN TERRITORY, OCCUPIED</option>' +
  370. '<option>PANAMA</option>' +
  371. '<option>PAPUA NEW GUINEA</option>' +
  372. '<option>PARAGUAY</option>' +
  373. '<option>PERU</option>' +
  374. '<option>PHILIPPINES</option>' +
  375. '<option>PITCAIRN</option>' +
  376. '<option>POLAND</option>' +
  377. '<option>PORTUGAL</option>' +
  378. '<option>PUERTO RICO</option>' +
  379. '<option>QATAR</option>' +
  380. '<option>REUNION</option>' +
  381. '<option>ROMANIA</option>' +
  382. '<option>RUSSIAN FEDERATION</option>' +
  383. '<option>RWANDA</option>' +
  384. '<option>SAINT HELENA</option>' +
  385. '<option>SAINT KITTS AND NEVIS</option>' +
  386. '<option>SAINT LUCIA</option>' +
  387. '<option>SAINT PIERRE AND MIQUELON</option>' +
  388. '<option>SAINT VINCENT AND THE GRENADINES</option>' +
  389. '<option>SAMOA</option>' +
  390. '<option>SAN MARINO</option>' +
  391. '<option>SAO TOME AND PRINCIPE</option>' +
  392. '<option>SAUDI ARABIA</option>' +
  393. '<option>SENEGAL</option>' +
  394. '<option>SERBIA AND MONTENEGRO</option>' +
  395. '<option>SEYCHELLES</option>' +
  396. '<option>SIERRA LEONE</option>' +
  397. '<option>SINGAPORE</option>' +
  398. '<option>SLOVAKIA</option>' +
  399. '<option>SLOVENIA</option>' +
  400. '<option>SOLOMON ISLANDS</option>' +
  401. '<option>SOMALIA</option>' +
  402. '<option>SOUTH AFRICA</option>' +
  403. '<option>SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS</option>' +
  404. '<option>SPAIN</option>' +
  405. '<option>SRI LANKA</option>' +
  406. '<option>SUDAN</option>' +
  407. '<option>SURINAME</option>' +
  408. '<option>SVALBARD AND JAN MAYEN</option>' +
  409. '<option>SWAZILAND</option>' +
  410. '<option>SWEDEN</option>' +
  411. '<option>SWITZERLAND</option>' +
  412. '<option>SYRIAN ARAB REPUBLIC</option>' +
  413. '<option>TAIWAN, PROVINCE OF CHINA</option>' +
  414. '<option>TAJIKISTAN</option>' +
  415. '<option>TANZANIA, UNITED REPUBLIC OF</option>' +
  416. '<option>THAILAND</option>' +
  417. '<option>TIMOR-LESTE</option>' +
  418. '<option>TOGO</option>' +
  419. '<option>TOKELAU</option>' +
  420. '<option>TONGA</option>' +
  421. '<option>TRINIDAD AND TOBAGO</option>' +
  422. '<option>TUNISIA</option>' +
  423. '<option>TURKEY</option>' +
  424. '<option>TURKMENISTAN</option>' +
  425. '<option>TURKS AND CAICOS ISLANDS</option>' +
  426. '<option>TUVALU</option>' +
  427. '<option>UGANDA</option>' +
  428. '<option>UKRAINE</option>' +
  429. '<option>UNITED ARAB EMIRATES</option>' +
  430. '<option>UNITED KINGDOM</option>' +
  431. '<option>UNITED STATES</option>' +
  432. '<option>UNITED STATES MINOR OUTLYING ISLANDS</option>' +
  433. '<option>URUGUAY</option>' +
  434. '<option>UZBEKISTAN</option>' +
  435. '<option>VANUATU</option>' +
  436. '<option>VENEZUELA</option>' +
  437. '<option>VIET NAM</option>' +
  438. '<option>VIRGIN ISLANDS, BRITISH</option>' +
  439. '<option>VIRGIN ISLANDS, U.S.</option>' +
  440. '<option>WALLIS AND FUTUNA</option>' +
  441. '<option>WESTERN SAHARA</option>' +
  442. '<option>YEMEN</option>' +
  443. '<option>ZAMBIA</option>' +
  444. '<option>ZIMBABWE</option>' +
  445.  
  446. '</select>' +
  447. '<span style="color:#f90500 !important; display: none" id="req_percentage" class="req_nationality' +
  448. y +
  449. '">The Nationality is required.</span>' +
  450. '</td>' +
  451. '<td>' +
  452. '<input id="DateOfBirth' +
  453. y +
  454. '" name="Applicant[' + i + '].DateOfBirth" style="height: 30px; font-size: 14px !important" type="text" onkeydown="return false" class=" datetimepick form-control Applicant' +
  455. y +
  456. ' keyup"/>' +
  457. '<span style="color:#f90500 !important; display: none" id="req_percentage" class="req_dob' +
  458. y +
  459. '">The Date Of Birth is required.</span>' +
  460. '</td>' +
  461. '<td>' +
  462. '<input id="PassportNumber' +
  463. y +
  464. '" name="Applicant[' + i + '].PassportNumber" style="height: 30px; font-size: 14px !important" type="text" class="form-control Applicant' +
  465. y +
  466. ' keyup"/>' +
  467. '<span style="color:#f90500 !important; display: none" id="req_percentage" class="req_passport' +
  468. y +
  469. '">The Passport Number is required.</span>' +
  470.  
  471. '</td>';
  472.  
  473. for (j = 0; j < c; j++) {
  474. data += '<td>' +
  475. '<input id="Column' +
  476. y +
  477. '" name="Applicant[' + i + '].ColumnValue' + j + '" style="height: 30px; font-size: 14px !important" type="text" class="form-control Applicant' +
  478. y +
  479. ' keyup"/>' +
  480. '<span style="color:#f90500 !important; display: none" id="req_percentage" class="req_column' +
  481. y + j +
  482. '">This Column value is required.</span>' +
  483.  
  484. '</td>'
  485.  
  486. ;
  487. }
  488.  
  489. data += '</tr>';
  490.  
  491. y += 1;
  492.  
  493. complete += data;
  494.  
  495.  
  496. }
  497.  
  498. var columns = "";
  499. var z = 1;
  500.  
  501. for (j = 0; j < c; j++) {
  502. columns += '<td style="text-align:center; !important;">' + '<b>COLUMN ' + z + ' NAME</b>' +
  503. '<input id="columnss' +
  504. z +
  505. '" name="columnss" style="height: 30px; font-size: 14px !important" type="text" class="form-control columnss' +
  506. z +
  507. ' keyup"/>' +
  508. '<span style="color:#f90500 !important; display: none" id="req_column_name" class="req_column_name' +
  509. z +
  510. '">This Column Name value is required.</span>' +
  511. '</td>';
  512. z += 1;
  513.  
  514. }
  515.  
  516. // Prepare the html table to display to the user and append the number of Applicants input and columns to into the table
  517. var final = '<table onChange="ValidateForm()" class="table table-bordered table-condensed" >' +
  518. '<tr>' +
  519. '<th colspan="16" class="tableheader">' +
  520. '<center >' +
  521. '<b>' +
  522. 'APPLICANT LIST' +
  523. '</b>' +
  524. '</center>' +
  525. '</th>' +
  526. '</tr>' +
  527. '<tr>' +
  528. '<td style="text-align:center; !important;">' +
  529. '<b>S/N</b>' +
  530. '</td>' +
  531. '<td style="text-align:center; !important;">' +
  532. '<b>FULL NAME<br/> (as per Certificate of Competency)</b>' +
  533. '</td>' +
  534. '<td style="text-align:center; !important;">' +
  535. '<b>RANK</b>' +
  536. '</td>' +
  537. '<td style="text-align:center; !important;">' +
  538. '<b>NATIONALITY</b>' +
  539. '</td>' +
  540. '<td style="text-align:center; !important;">' +
  541. '<b>DATE OF BIRTH</b>' +
  542. '</td>' +
  543. '<td style="text-align:center; !important;">' +
  544. '<b>PASSPORT NUMBER</b>' +
  545. '</td>' +
  546.  
  547. columns +
  548.  
  549. '</tr>' +
  550.  
  551.  
  552. complete + '</table>';
  553.  
  554. $('#dynamic_table').append(final);
  555.  
  556. $(".datetimepick").datepicker({
  557. changeMonth: true,
  558. changeYear: true,
  559. dateFormat: "dd/mm/yy",
  560. yearRange: "-80:+00"
  561. });
  562. $(".datetimepick").datepicker("option", "showAnim", "clip");
  563.  
  564.  
  565.  
  566.  
  567. }
  568.  
  569. // The following function is used to redirect user to the other page while in the server side create necessary session data
  570. function Selection(id) {
  571.  
  572. $.ajax({
  573. type: "GET",
  574. url: "/PostReference",
  575. dataType: "json",
  576. data: {
  577. id: id
  578. },
  579. contentType: "application/json; charset=utf-8",
  580. success: function(returndata) {
  581. if (returndata.ok)
  582. window.location = returndata.newurl;
  583. else
  584. window.alert(returndata.message);
  585. }
  586.  
  587. });
  588. }
  589.  
  590. // The following function is to find out the number of applicants that user checked to be deleted from the system.
  591. function deleteApplicants() {
  592.  
  593. var IsChecked = $('.chkbox:checkbox:checked').length > 0;
  594. var id = '';
  595. $('.chkbox:checked').each(function() {
  596.  
  597. var trid = $(this).closest('tr').attr('id');
  598.  
  599. id = id + '|' + trid;
  600.  
  601. });
  602.  
  603. // Make sure that there are atleast one applicant
  604. if (id == '') {
  605. alert('Please select at least one applicant.');
  606. }
  607. // Using ajax to request to the server side
  608. if (id != '') {
  609. var c = confirm("Delete selected Applicants(s)?")
  610.  
  611. if (c) {
  612.  
  613. $.ajax({
  614. type: "GET",
  615. url: "/Delete",
  616. dataType: "json",
  617. data: {
  618. id: id,
  619. param: 8
  620. },
  621. contentType: "application/json; charset=utf-8",
  622. success: function(returndata) {
  623. if (returndata.ok)
  624.  
  625. window.location = "/CompleteMessage";
  626. else
  627. window.alert(returndata.message);
  628. }
  629.  
  630. });
  631. }
  632. }
  633. }
  634.  
  635.  
  636.  
  637.  
  638. // Due to the form being extremely lengthy.
  639. // The following code is to automatically submit the entire form input to the server and saved it so the user may continue in the future or prevent missing information if accidentally refresh the page
  640. setInterval(function() {
  641. $('#applicantForm').ajaxSubmit({
  642. url: 'SaveDraft',
  643. success: function(data, textStatus) {
  644. if (data.success) {
  645. savedSuccess();
  646. }
  647. }
  648. });
  649. }, 30000);
  650.  
  651. // Display success alert and notification animation to the user
  652. function savedSuccess() {
  653.  
  654. $("#success-alert").fadeTo(2000, 500).slideUp(500, function() {
  655. $("#success-alert").slideUp(500);
  656. });
  657. }
  658.  
  659.  
  660. // Calculate the limit of text in input field and display the appropriate message
  661. function calculateTextLimit(that) {
  662. var inputField = that.id.substring(8);
  663.  
  664. $('#limit800' + inputField).hide();
  665. max = that.getAttribute("maxlength");
  666. var len = $(that).val().length;
  667. if (len >= max) {
  668. $('#charNum' + inputField).text('(you have reached the characters limit!)');
  669. } else {
  670. var char = max - len;
  671. $('#charNum' + inputField).text('(' + char + ' characters left)');
  672. }
  673. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement