{"id":7159,"date":"2026-09-25T05:55:32","date_gmt":"2026-09-25T05:55:32","guid":{"rendered":"https:\/\/grad.jfn.ac.lk\/?page_id=7159"},"modified":"2026-09-25T07:13:20","modified_gmt":"2026-09-25T07:13:20","slug":"7159-2","status":"publish","type":"page","link":"https:\/\/grad.jfn.ac.lk\/?page_id=7159","title":{"rendered":"Online Application Portal"},"content":{"rendered":"\n\n    <script>\n        const FGS_MAX_FILE_SIZE = 5242880;\n        const FGS_AJAX_URL = \"https:\/\/grad.jfn.ac.lk\/wp-admin\/admin-ajax.php\";\n    <\/script>\n\n    <div class=\"fgs-wrapper\">\n        <div class=\"fgs-card\">\n            <div class=\"fgs-header\">\n                <h2>FACULTY OF GRADUATE STUDIES<\/h2>\n                <p>Application for Postgraduate Programs<\/p>\n            <\/div>\n\n            <div id=\"fgsMessage\" class=\"fgs-message\" tabindex=\"-1\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"><\/div>\n\n            <form id=\"fgsApplicationForm\" enctype=\"multipart\/form-data\">\n\n                <!-- 1. PROGRAMME -->\n                <div class=\"fgs-section\">\n                    <div class=\"fgs-section-title\">\n                        <span class=\"fgs-number\">1<\/span> Programme Applied For\n                    <\/div>\n                    <div class=\"fgs-grid\">\n                        <div class=\"fgs-field fgs-full\">\n                            <label>Select Programme <span class=\"fgs-required\">*<\/span><\/label>\n                            <select name=\"course_id\" id=\"fgsCourse\" required>\n                                <option value=\"\">-- Select a programme now calling for applications --<\/option>\n                                                                    <option value=\"f58bd1b0-8014-44bd-9df2-cb4912714ae5\" data-closing=\"30 Nov 2026\" >\n                                        Master of Tamil \u2013 Batch XI                                    <\/option>\n                                                                    <option value=\"545e8a25-26d0-48ef-b82c-da3a847f17eb\" data-closing=\"30 Nov 2026\" >\n                                        Master of Public Administration (Tamil Medium) \u2013 Batch V                                    <\/option>\n                                                                    <option value=\"af6f90a0-2bf1-4607-8065-88cf72f20364\" data-closing=\"30 Nov 2026\" >\n                                        Master of Public Administration (English Medium) \u2013 Batch V                                    <\/option>\n                                                                    <option value=\"61e5d633-26af-418c-ac33-fb815fb81b32\" data-closing=\"30 Nov 2026\" >\n                                        Master of Cultural Studies \u2013 Batch VI                                    <\/option>\n                                                            <\/select>\n                            <small id=\"fgsClosingNote\"><\/small>\n                        <\/div>\n                    <\/div>\n                <\/div>\n\n                <!-- 2. PERSONAL DETAILS -->\n                <div class=\"fgs-section\">\n                    <div class=\"fgs-section-title\">\n                        <span class=\"fgs-number\">2<\/span> Personal Details\n                    <\/div>\n                    <div class=\"fgs-grid\" id=\"personalContainer\">\n                        <div class=\"fgs-field fgs-full\">\n                            <label>Full Name in English <span class=\"fgs-required\">*<\/span><\/label>\n                            <input type=\"text\" name=\"full_name\" required>\n                        <\/div>\n                        <div class=\"fgs-field\">\n                            <label>Title <span class=\"fgs-required\">*<\/span><\/label>\n                            <select name=\"title\" required>\n                                <option value=\"\">Select Title<\/option>\n                                <option value=\"Rev\">Rev.<\/option>\n                                <option value=\"Mr\">Mr.<\/option>\n                                <option value=\"Mrs\">Mrs.<\/option>\n                                <option value=\"Miss\">Miss<\/option>\n                                <option value=\"Dr\">Dr.<\/option>\n                                <option value=\"Prof\">Prof.<\/option>\n                            <\/select>\n                        <\/div>\n                        <div class=\"fgs-field\">\n                            <label>Name with Initials <span class=\"fgs-required\">*<\/span><\/label>\n                            <input type=\"text\" name=\"name_initials\" placeholder=\"e.g. Naresh N\" required>\n                        <\/div>\n                        <div class=\"fgs-field fgs-full\">\n                            <label>Permanent Address <span class=\"fgs-required\">*<\/span><\/label>\n                            <textarea name=\"permanent_address\" required><\/textarea>\n                        <\/div>\n                        <div class=\"fgs-field fgs-full\">\n                            <label>Address for Correspondence<\/label>\n                            <textarea name=\"correspondence_address\" placeholder=\"Leave blank if same as permanent address\"><\/textarea>\n                        <\/div>\n                        <div class=\"fgs-field\">\n                            <label>Mobile Number <span class=\"fgs-required\">*<\/span><\/label>\n                            <input type=\"tel\" name=\"mobile\" pattern=\"[0-9+\\s\\-]{9,20}\" title=\"Enter a valid phone number\" required>\n                        <\/div>\n                        <div class=\"fgs-field\">\n                            <label>Residential Telephone<\/label>\n                            <input type=\"tel\" name=\"tel_residential\" pattern=\"[0-9+\\s\\-]{9,20}\" title=\"Enter a valid phone number\">\n                        <\/div>\n                        <div class=\"fgs-field\">\n                            <label>Office Telephone<\/label>\n                            <input type=\"tel\" name=\"tel_office\" pattern=\"[0-9+\\s\\-]{9,20}\" title=\"Enter a valid phone number\">\n                        <\/div>\n                        <div class=\"fgs-field\">\n                            <label>Email Address <span class=\"fgs-required\">*<\/span><\/label>\n                            <input type=\"email\" name=\"email\" required>\n                        <\/div>\n                        <div class=\"fgs-field\">\n                            <label>District <span class=\"fgs-required\">*<\/span><\/label>\n                            <select name=\"district\" required>\n                                <option value=\"\">Select District<\/option>\n                                                                    <option value=\"Ampara\">Ampara<\/option>\n                                                                    <option value=\"Anuradhapura\">Anuradhapura<\/option>\n                                                                    <option value=\"Badulla\">Badulla<\/option>\n                                                                    <option value=\"Batticaloa\">Batticaloa<\/option>\n                                                                    <option value=\"Colombo\">Colombo<\/option>\n                                                                    <option value=\"Galle\">Galle<\/option>\n                                                                    <option value=\"Gampaha\">Gampaha<\/option>\n                                                                    <option value=\"Hambantota\">Hambantota<\/option>\n                                                                    <option value=\"Jaffna\">Jaffna<\/option>\n                                                                    <option value=\"Kalutara\">Kalutara<\/option>\n                                                                    <option value=\"Kandy\">Kandy<\/option>\n                                                                    <option value=\"Kegalle\">Kegalle<\/option>\n                                                                    <option value=\"Kilinochchi\">Kilinochchi<\/option>\n                                                                    <option value=\"Kurunegala\">Kurunegala<\/option>\n                                                                    <option value=\"Mannar\">Mannar<\/option>\n                                                                    <option value=\"Matale\">Matale<\/option>\n                                                                    <option value=\"Matara\">Matara<\/option>\n                                                                    <option value=\"Monaragala\">Monaragala<\/option>\n                                                                    <option value=\"Mullaitivu\">Mullaitivu<\/option>\n                                                                    <option value=\"Nuwara Eliya\">Nuwara Eliya<\/option>\n                                                                    <option value=\"Polonnaruwa\">Polonnaruwa<\/option>\n                                                                    <option value=\"Puttalam\">Puttalam<\/option>\n                                                                    <option value=\"Ratnapura\">Ratnapura<\/option>\n                                                                    <option value=\"Trincomalee\">Trincomalee<\/option>\n                                                                    <option value=\"Vavuniya\">Vavuniya<\/option>\n                                                                    <option value=\"Outside Sri Lanka\">Outside Sri Lanka<\/option>\n                                                            <\/select>\n                        <\/div>\n                        <div class=\"fgs-field\">\n                            <label>NIC \/ Passport Number <span class=\"fgs-required\">*<\/span><\/label>\n                            <input type=\"text\" name=\"nic\" required>\n                        <\/div>\n                        <div class=\"fgs-field\">\n                            <label>Date of Birth <span class=\"fgs-required\">*<\/span><\/label>\n                            <input type=\"date\" class=\"fgs-dob\" name=\"dob\" required>\n                        <\/div>\n                        <div class=\"fgs-field\">\n                            <label>Age (auto-calculated)<\/label>\n                            <input type=\"text\" class=\"fgs-age\" name=\"age\" readonly placeholder=\"Calculated automatically from the Date of Birth\">\n                            <small>Please check that this age is correct. If not, correct your Date of Birth.<\/small>\n                        <\/div>\n                        <div class=\"fgs-field\">\n                            <label>Citizenship <span class=\"fgs-required\">*<\/span><\/label>\n                            <input type=\"text\" name=\"citizenship\" value=\"Sri Lankan\" required>\n                        <\/div>\n                        <div class=\"fgs-field\">\n                            <label>Civil Status <span class=\"fgs-required\">*<\/span><\/label>\n                            <select name=\"civil_status\" required>\n                                <option value=\"\">Select Status<\/option>\n                                <option value=\"Single\">Single<\/option>\n                                <option value=\"Married\">Married<\/option>\n                                <option value=\"Other\">Other<\/option>\n                            <\/select>\n                        <\/div>\n                        <div class=\"fgs-field\">\n                            <label>Gender <span class=\"fgs-required\">*<\/span><\/label>\n                            <select name=\"sex\" required>\n                                <option value=\"\">Select Gender<\/option>\n                                <option value=\"Male\">Male<\/option>\n                                <option value=\"Female\">Female<\/option>\n                            <\/select>\n                        <\/div>\n                    <\/div>\n                <\/div>\n\n                <!-- 3. ACADEMIC QUALIFICATIONS -->\n                <div class=\"fgs-section\">\n                    <div class=\"fgs-section-title\">\n                        <span class=\"fgs-number\">3<\/span> Academic Qualifications\n                    <\/div>\n                    <div id=\"academicContainer\">\n                        <div class=\"fgs-repeat academic-row\">\n                            <div class=\"fgs-repeat-title\">Academic Qualification 1<\/div>\n                            <div class=\"fgs-grid\">\n                                <div class=\"fgs-field\">\n                                    <label>Degree \/ Qualification<\/label>\n                                    <input type=\"text\" name=\"academic[0][degree]\">\n                                <\/div>\n                                <div class=\"fgs-field\">\n                                    <label>University \/ Institution<\/label>\n                                    <input type=\"text\" name=\"academic[0][university]\">\n                                <\/div>\n                                <div class=\"fgs-field\">\n                                    <label>Effective Date<\/label>\n                                    <input type=\"date\" name=\"academic[0][effective_date]\">\n                                <\/div>\n                                <div class=\"fgs-field\">\n                                    <label>General \/ Special<\/label>\n                                    <input type=\"text\" name=\"academic[0][general_special]\">\n                                <\/div>\n                                <div class=\"fgs-field fgs-full\">\n                                    <label>Subjects Offered<\/label>\n                                    <textarea name=\"academic[0][subjects]\"><\/textarea>\n                                <\/div>\n                                <div class=\"fgs-field\">\n                                    <label>Class Obtained<\/label>\n                                    <select name=\"academic[0][class_obtained]\">\n                                        <option value=\"\">Select<\/option>\n                                        <option value=\"First Class\">First Class<\/option>\n                                        <option value=\"Second Class (Upper)\">Second Class (Upper)<\/option>\n                                        <option value=\"Second Class (Lower)\">Second Class (Lower)<\/option>\n                                        <option value=\"Pass\">Pass<\/option>\n                                        <option value=\"Other\">Other<\/option>\n                                    <\/select>\n                                <\/div>\n                                <div class=\"fgs-field\">\n                                    <label>Course Duration<\/label>\n                                    <input type=\"text\" name=\"academic[0][course_duration]\" placeholder=\"e.g. 4 years\">\n                                <\/div>\n                            <\/div>\n                        <\/div>\n                    <\/div>\n                    <button type=\"button\" class=\"fgs-add\" id=\"addAcademicRow\">+ Add Another Academic Qualification<\/button>\n                <\/div>\n\n                <!-- 4. PROFESSIONAL QUALIFICATIONS -->\n                <div class=\"fgs-section\">\n                    <div class=\"fgs-section-title\">\n                        <span class=\"fgs-number\">4<\/span> Professional Qualifications\n                    <\/div>\n                    <div id=\"professionalContainer\">\n                        <div class=\"fgs-repeat professional-row\">\n                            <div class=\"fgs-repeat-title\">Professional Qualification 1<\/div>\n                            <div class=\"fgs-grid\">\n                                <div class=\"fgs-field\">\n                                    <label>Qualification \/ Certificate<\/label>\n                                    <input type=\"text\" name=\"professional[0][qualification]\">\n                                <\/div>\n                                <div class=\"fgs-field\">\n                                    <label>Institution \/ Body<\/label>\n                                    <input type=\"text\" name=\"professional[0][institution]\">\n                                <\/div>\n                                <div class=\"fgs-field\">\n                                    <label>Effective Date<\/label>\n                                    <input type=\"date\" name=\"professional[0][effective_date]\">\n                                <\/div>\n                                <div class=\"fgs-field\">\n                                    <label>Duration \/ Level<\/label>\n                                    <input type=\"text\" name=\"professional[0][duration]\">\n                                <\/div>\n                            <\/div>\n                        <\/div>\n                    <\/div>\n                    <button type=\"button\" class=\"fgs-add\" id=\"addProfessionalRow\">+ Add Another Professional Qualification<\/button>\n                <\/div>\n\n                <!-- 5. WORK EXPERIENCE -->\n                <div class=\"fgs-section\">\n                    <div class=\"fgs-section-title\">\n                        <span class=\"fgs-number\">5<\/span> Work Experience\n                    <\/div>\n                    <div id=\"experienceContainer\">\n                        <div class=\"fgs-repeat experience-row\">\n                            <div class=\"fgs-repeat-title\">Employment \/ Experience 1<\/div>\n                            <div class=\"fgs-grid\">\n                                <div class=\"fgs-field\">\n                                    <label>Designation \/ Post<\/label>\n                                    <input type=\"text\" name=\"experience[0][designation]\">\n                                <\/div>\n                                <div class=\"fgs-field\">\n                                    <label>Organization \/ Department<\/label>\n                                    <input type=\"text\" name=\"experience[0][organization]\">\n                                <\/div>\n                                <div class=\"fgs-field\">\n                                    <label>From<\/label>\n                                    <input type=\"date\" class=\"fgs-exp-from\" name=\"experience[0][from_date]\">\n                                <\/div>\n                                <div class=\"fgs-field\">\n                                    <label>To<\/label>\n                                    <input type=\"date\" class=\"fgs-exp-to\" name=\"experience[0][to_date]\">\n                                <\/div>\n                                <div class=\"fgs-field fgs-full\">\n                                    <label class=\"fgs-check-label\"><input type=\"checkbox\" class=\"fgs-exp-current\" name=\"experience[0][current]\" value=\"1\"> Currently working here<\/label>\n                                <\/div>\n                                <div class=\"fgs-field fgs-full\">\n                                    <label>Total Experience (auto-calculated)<\/label>\n                                    <input type=\"text\" class=\"fgs-exp-duration\" name=\"experience[0][duration]\" readonly placeholder=\"Calculated automatically from the dates\">\n                                <\/div>\n                            <\/div>\n                        <\/div>\n                    <\/div>\n                    <button type=\"button\" class=\"fgs-add\" id=\"addExperienceRow\">+ Add Another Work Experience<\/button>\n                <\/div>\n\n                <!-- 6. CURRENT STUDENTSHIP -->\n                <div class=\"fgs-section\">\n                    <div class=\"fgs-section-title\">\n                        <span class=\"fgs-number\">6<\/span> Current Studentship\n                    <\/div>\n                    <div class=\"fgs-grid\">\n                        <div class=\"fgs-field fgs-full\">\n                            <label>Are you a currently registered student of any degree\/diploma programme conducted by the University of Jaffna or any other Higher Educational Institute? <span class=\"fgs-required\">*<\/span><\/label>\n                            <div class=\"fgs-radio-group\">\n                                <label><input type=\"radio\" name=\"currently_registered\" value=\"Yes\" required> YES<\/label>\n                                <label><input type=\"radio\" name=\"currently_registered\" value=\"No\"> NO<\/label>\n                            <\/div>\n                        <\/div>\n                        <div id=\"fgsStudentFields\" class=\"fgs-grid fgs-full\" style=\"display:none\">\n                            <div class=\"fgs-field fgs-full\">\n                                <label>Name of the Programme <span class=\"fgs-required\">*<\/span><\/label>\n                                <input type=\"text\" name=\"current_programme\" disabled>\n                            <\/div>\n                            <div class=\"fgs-field\">\n                                <label>Name of the University \/ HEI <span class=\"fgs-required\">*<\/span><\/label>\n                                <input type=\"text\" name=\"current_university\" disabled>\n                            <\/div>\n                            <div class=\"fgs-field fgs-full\">\n                                <label>Current Status of the Programme <span class=\"fgs-required\">*<\/span><\/label>\n                                <input type=\"text\" name=\"current_status\" disabled>\n                            <\/div>\n                        <\/div>\n                    <\/div>\n                <\/div>\n\n                <!-- 7. OTHER QUALIFICATIONS (open ended) -->\n                <div class=\"fgs-section\">\n                    <div class=\"fgs-section-title\">\n                        <span class=\"fgs-number\">7<\/span> Other Qualifications\n                    <\/div>\n                    <div class=\"fgs-grid\">\n                        <div class=\"fgs-field fgs-full\">\n                            <label>Any Other Qualifications \/ Achievements<\/label>\n                            <textarea name=\"other_qualifications\" rows=\"5\" placeholder=\"Optional. List any other qualifications, short courses, awards, publications, research or achievements not mentioned above.\"><\/textarea>\n                        <\/div>\n                    <\/div>\n                <\/div>\n\n                <!-- 8. ATTACHMENTS -->\n                <div class=\"fgs-section\">\n                    <div class=\"fgs-section-title\">\n                        <span class=\"fgs-number\">8<\/span> Document Uploads (PDF Only)\n                    <\/div>\n                    <div class=\"fgs-grid\">\n                        <div class=\"fgs-field fgs-file\">\n                            <label>National Identity Card (NIC) \/ Passport <span class=\"fgs-required\">*<\/span><\/label>\n                            <input type=\"file\" name=\"doc_nic\" accept=\".pdf\" required>\n                            <small>Max file size: 5 MB<\/small>\n                        <\/div>\n                        <div class=\"fgs-field fgs-file\">\n                            <label>Birth Certificate <span class=\"fgs-required\">*<\/span><\/label>\n                            <input type=\"file\" name=\"doc_birth\" accept=\".pdf\" required>\n                            <small>Max file size: 5 MB<\/small>\n                        <\/div>\n                        <div class=\"fgs-field fgs-file\">\n                            <label>Degree Certificates \/ Transcripts \/ Statements<\/label>\n                            <input type=\"file\" name=\"doc_degree\" accept=\".pdf\">\n                            <small>Max file size: 5 MB<\/small>\n                        <\/div>\n                        <div class=\"fgs-field fgs-file\">\n                            <label>Payment Receipt <span class=\"fgs-required\">*<\/span><\/label>\n                            <input type=\"file\" name=\"doc_payment\" accept=\".pdf\" required>\n                            <small>Max file size: 5 MB<\/small>\n                        <\/div>\n                        <div class=\"fgs-field fgs-file fgs-full\">\n                            <label>Other Supporting Documents (Optional)<\/label>\n                            <input type=\"file\" name=\"doc_other\" accept=\".pdf\">\n                            <small>Max file size: 5 MB<\/small>\n                        <\/div>\n                    <\/div>\n                <\/div>\n\n                <!-- DECLARATION -->\n                <div class=\"fgs-section\">\n                    <div class=\"fgs-declaration\">\n                        <h4 class=\"fgs-declaration-title\">Declaration<\/h4>\n                        <p>I do hereby certify that the information furnished herein are true and correct to the best of my knowledge. In the event of my application being accepted for registration for the above Degree, I am aware that I will be bound by the rules and regulations already made or that may hereafter be made governing the award of higher degrees of the University of Jaffna, Sri Lanka.<\/p>\n                        <label>\n                            <input type=\"checkbox\" name=\"declaration\" value=\"1\" required>\n                            <span>I agree to the above declaration. <span class=\"fgs-required\">*<\/span><\/span>\n                        <\/label>\n                    <\/div>\n                <\/div>\n\n                <div class=\"fgs-submit-area\">\n                    <input type=\"hidden\" id=\"fgs_nonce\" name=\"fgs_nonce\" value=\"c9d4198317\" \/><input type=\"hidden\" name=\"_wp_http_referer\" value=\"\/index.php?rest_route=%2Fwp%2Fv2%2Fpages%2F7159\" \/>                    <button type=\"submit\" id=\"fgsSubmitBtn\" class=\"fgs-submit\">Submit Application<\/button>\n                    <div id=\"fgsLoading\" class=\"fgs-loading\">Processing application and uploading files. Please do not close or refresh this page...<\/div>\n                <\/div>\n\n            <\/form>\n        <\/div>\n    <\/div>\n\n    <script>\n    (function (fgsInit) {\n        if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', fgsInit); } else { fgsInit(); }\n    })(function () {\n\n        let fgsLastReceipt = null;\n\n        \/\/ Show the message before focusing or scrolling: hidden elements cannot scroll.\n        function fgsShowMessage(messageDiv) {\n            messageDiv.style.display = 'block';\n            messageDiv.focus({ preventScroll: true });\n            const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n            messageDiv.scrollIntoView({ behavior: reduceMotion ? 'instant' : 'smooth', block: 'start' });\n        }\n\n        function fgsEsc(s) {\n            return String(s == null ? '' : s).replace(\/[&<>\"']\/g, c => ({'&':'&amp;','<':'&lt;','>':'&gt;','\"':'&quot;',\"'\":'&#39;'}[c]));\n        }\n\n        function fgsFieldValue(el) {\n            if (el.type === 'file') return el.files.length ? el.files[0].name : '';\n            if (el.type === 'radio') return el.checked ? el.value : '';\n            if (el.type === 'checkbox') return el.checked ? (el.name === 'declaration' ? 'I do hereby certify that the information furnished herein are true and correct to the best of my knowledge. In the event of my application being accepted for registration for the above Degree, I am aware that I will be bound by the rules and regulations already made or that may hereafter be made governing the award of higher degrees of the University of Jaffna, Sri Lanka.' : 'Yes') : '';\n            if (el.tagName === 'SELECT') return el.value ? el.options[el.selectedIndex].text : '';\n            return el.value.trim();\n        }\n\n        function fgsFieldLabel(el) {\n            const lbl = el.closest('.fgs-field') && el.closest('.fgs-field').querySelector('label');\n            return lbl ? lbl.textContent.replace('*', '').replace(\/\\s*\\(auto-calculated\\)\/i, '').trim() : 'Declaration';\n        }\n\n        \/\/ Captures all filled values (grouped by section \/ repeat block) BEFORE form.reset()\n        function fgsBuildSnapshot(form) {\n            const sections = [];\n            form.querySelectorAll('.fgs-section').forEach(sec => {\n                const titleEl = sec.querySelector('.fgs-section-title');\n                const title = titleEl ? titleEl.textContent.replace(\/^\\s*\\d+\\s*\/, '').trim() : 'Declaration';\n                const groups = [];\n                const repeats = sec.querySelectorAll('.fgs-repeat');\n                const collect = (root) => {\n                    const rows = [];\n                    root.querySelectorAll('input, select, textarea').forEach(el => {\n                        if (el.type === 'hidden' || el.type === 'submit' || el.type === 'button') return;\n                        if (root === sec && el.closest('.fgs-repeat')) return;\n                        const v = fgsFieldValue(el);\n                        if (v !== '') rows.push([fgsFieldLabel(el), v]);\n                    });\n                    return rows;\n                };\n                const own = collect(sec);\n                if (own.length) groups.push({ title: '', rows: own });\n                repeats.forEach(r => {\n                    const rows = collect(r);\n                    const curBox = r.querySelector('.fgs-exp-current');\n                    if (curBox && curBox.checked) {\n                        const di = rows.findIndex(x => x[0] === 'Designation \/ Post');\n                        if (di >= 0) { rows[di][2] = 'Currently working'; }\n                        else { rows.unshift(['Designation \/ Post', '', 'Currently working']); }\n                        for (let k = rows.length - 1; k >= 0; k--) {\n                            if (rows[k][0] === 'Currently working here') rows.splice(k, 1);\n                        }\n                    }\n                    if (rows.length) {\n                        const t = r.querySelector('.fgs-repeat-title');\n                        groups.push({ title: t ? t.textContent.trim() : '', rows: rows });\n                    }\n                });\n                if (groups.length) sections.push({ title: title, groups: groups });\n            });\n            return sections;\n        }\n\n        function fgsPrintReceipt(r) {\n            if (!r) return;\n            let body = '';\n            r.sections.forEach((s, i) => {\n                body += '<h3>' + (i + 1) + '. ' + fgsEsc(s.title) + '<\/h3>';\n                s.groups.forEach(g => {\n                    if (g.title) body += '<h4>' + fgsEsc(g.title) + '<\/h4>';\n                    body += '<table>' + g.rows.map(row =>\n                        '<tr><th>' + fgsEsc(row[0]) + '<\/th><td>' + fgsEsc(row[1]).replace(\/\\n\/g, '<br>') + (row[2] ? (row[1] ? ' - ' : '') + '<b>' + fgsEsc(row[2]) + '<\/b>' : '') + '<\/td><\/tr>'\n                    ).join('') + '<\/table>';\n                });\n            });\n            const html = '<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Application ' + fgsEsc(r.appNo) + '<\/title><style>' +\n                '@page{size:A4;margin:15mm}body{font-family:Arial,sans-serif;color:#000;font-size:12px;margin:0}' +\n                '.hd{text-align:center;border-bottom:2px solid #004085;padding-bottom:8px;margin-bottom:12px}' +\n                '.hd h1{font-size:16px;margin:0;color:#004085}.hd h2{font-size:14px;margin:4px 0 0}.hd p{margin:2px 0}' +\n                '.meta{display:flex;justify-content:space-between;border:2px solid #004085;padding:8px 12px;margin-bottom:12px}' +\n                '.meta b{font-size:16px;letter-spacing:1px}' +\n                'h3{background:#004085;color:#fff;font-size:13px;padding:4px 8px;margin:14px 0 6px;-webkit-print-color-adjust:exact;print-color-adjust:exact}' +\n                'h4{font-size:12px;margin:8px 0 4px}table{width:100%;border-collapse:collapse;page-break-inside:avoid}' +\n                'th,td{border:1px solid #999;padding:4px 6px;text-align:left;vertical-align:top}th{width:35%;background:#f2f2f2}' +\n                '.sig{display:flex;justify-content:space-between;margin-top:40px}.sig div{border-top:1px dotted #000;width:40%;text-align:center;padding-top:4px}' +\n                '.ft{margin-top:20px;font-size:10px;color:#555;text-align:center}' +\n                '<\/style><\/head><body>' +\n                '<div class=\"hd\"><h1>UNIVERSITY OF JAFFNA<\/h1><h2>FACULTY OF GRADUATE STUDIES<\/h2>' +\n                '<p>Application for Postgraduate Programmes' + (r.programme ? ' &mdash; ' + fgsEsc(r.programme) : '') + (r.batch ? ' (' + fgsEsc(r.batch) + ')' : '') + '<\/p><\/div>' +\n                '<div class=\"meta\"><div>Application No:<br><b>' + fgsEsc(r.appNo || 'N\/A') + '<\/b><\/div>' +\n                '<div style=\"text-align:right\">Submitted on:<br>' + fgsEsc(r.submittedAt) + '<\/div><\/div>' +\n                body +\n                '<div class=\"sig\"><div>Date<\/div><div>Signature of Applicant<\/div><\/div>' +\n                '<div class=\"ft\">This is a computer-generated copy of your online application. Quote the Application No. in all correspondence.<\/div>' +\n                '<\/body><\/html>';\n            const w = window.open('', '_blank', 'width=900,height=1000');\n            if (!w) { alert('Please allow pop-ups for this site to print your application.'); return; }\n            w.document.open();\n            w.document.write(html);\n            w.document.close();\n            w.onload = function () { w.focus(); w.print(); };\n            setTimeout(function () { try { w.focus(); w.print(); } catch (e) {} }, 600);\n        }\n\n        \/* ---------- Programme closing-date note ---------- *\/\n        (function () {\n            const sel = document.getElementById('fgsCourse');\n            const note = document.getElementById('fgsClosingNote');\n            const upd = () => {\n                const o = sel.options[sel.selectedIndex];\n                const d = o ? o.getAttribute('data-closing') : '';\n                note.textContent = d ? 'Closing date: ' + d : '';\n            };\n            sel.addEventListener('change', upd); upd();\n        })();\n\n        \/* ---------- Current studentship (YES \/ NO) ---------- *\/\n        const fgsStudentBox = document.getElementById('fgsStudentFields');\n        function fgsToggleStudent() {\n            const checked = document.querySelector('input[name=\"currently_registered\"]:checked');\n            const yes = !!checked && checked.value === 'Yes';\n            fgsStudentBox.style.display = yes ? '' : 'none';\n            fgsStudentBox.querySelectorAll('input').forEach(function (i) {\n                i.disabled = !yes;\n                i.required = yes;\n                if (!yes) i.value = '';\n            });\n        }\n        document.querySelectorAll('input[name=\"currently_registered\"]').forEach(function (r) {\n            r.addEventListener('change', fgsToggleStudent);\n        });\n        fgsToggleStudent();\n\n        \/* ---------- Work experience: auto-calculated duration ---------- *\/\n        function fgsToday() {\n            const d = new Date();\n            return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0');\n        }\n\n        function fgsDiff(fromStr, toStr) {\n            const f = fromStr.split('-').map(Number);\n            const t = toStr.split('-').map(Number);\n            let y = t[0] - f[0], m = t[1] - f[1], d = t[2] - f[2];\n            if (d < 0) { m--; d += new Date(t[0], t[1] - 1, 0).getDate(); } \/\/ days in the month before the \"To\" month\n            if (m < 0) { y--; m += 12; }\n            return { y: y, m: m, d: d };\n        }\n\n        function fgsFormatDiff(o) {\n            const parts = [];\n            if (o.y > 0) parts.push(o.y + (o.y === 1 ? ' year' : ' years'));\n            if (o.m > 0) parts.push(o.m + (o.m === 1 ? ' month' : ' months'));\n            if (o.d > 0) parts.push(o.d + (o.d === 1 ? ' day' : ' days'));\n            return parts.length ? parts.join(', ') : '0 days';\n        }\n\n        function fgsUpdateExperience(row) {\n            const from = row.querySelector('.fgs-exp-from');\n            const to = row.querySelector('.fgs-exp-to');\n            const cur = row.querySelector('.fgs-exp-current');\n            const out = row.querySelector('.fgs-exp-duration');\n            const today = fgsToday();\n\n            from.max = today;\n            to.max = today;\n            to.disabled = cur.checked;\n            if (cur.checked) to.value = '';\n            to.setCustomValidity('');\n            out.value = '';\n\n            if (!from.value) return;\n            const end = cur.checked ? today : to.value;\n            if (!end) return;\n\n            if (end < from.value) {\n                to.setCustomValidity('The \"To\" date cannot be earlier than the \"From\" date.');\n                out.value = 'Invalid date range';\n                return;\n            }\n            out.value = fgsFormatDiff(fgsDiff(from.value, end));\n        }\n\n        const fgsExpContainer = document.getElementById('experienceContainer');\n        ['input', 'change'].forEach(function (evt) {\n            fgsExpContainer.addEventListener(evt, function (e) {\n                if (e.target.matches('.fgs-exp-from, .fgs-exp-to, .fgs-exp-current')) {\n                    fgsUpdateExperience(e.target.closest('.experience-row'));\n                }\n            });\n        });\n        fgsExpContainer.querySelectorAll('.experience-row').forEach(fgsUpdateExperience);\n\n        \/* ---------- Age: years, months, days (same technique as Total Experience) ---------- *\/\n        function fgsFormatAge(o) {\n            return o.y + (o.y === 1 ? ' year' : ' years') + ', ' +\n                   o.m + (o.m === 1 ? ' month' : ' months') + ', ' +\n                   o.d + (o.d === 1 ? ' day' : ' days');\n        }\n\n        function fgsUpdateAge(box) {\n            const dob = box.querySelector('.fgs-dob');\n            const out = box.querySelector('.fgs-age');\n            if (!dob || !out) return;\n            const today = fgsToday();\n\n            dob.max = today;\n            dob.setCustomValidity('');\n            out.value = '';\n\n            if (!dob.value) return;\n            if (dob.value > today) {\n                dob.setCustomValidity('Date of birth cannot be in the future.');\n                out.value = 'Invalid date of birth';\n                return;\n            }\n            out.value = fgsFormatAge(fgsDiff(dob.value, today));\n        }\n\n        const fgsPersonal = document.getElementById('personalContainer');\n        ['input', 'change'].forEach(function (evt) {\n            fgsPersonal.addEventListener(evt, function (e) {\n                if (e.target.matches('.fgs-dob')) {\n                    fgsUpdateAge(fgsPersonal);\n                }\n            });\n        });\n        fgsUpdateAge(fgsPersonal);\n\n        \/* ---------- Repeating rows ---------- *\/\n        let academicIndex = 1;\n        document.getElementById('addAcademicRow').addEventListener('click', function () {\n            const container = document.getElementById('academicContainer');\n            const row = document.createElement('div');\n            row.className = 'fgs-repeat academic-row';\n            row.innerHTML = `\n                <button type=\"button\" class=\"fgs-remove\">&times; Remove<\/button>\n                <div class=\"fgs-repeat-title\">Academic Qualification ${academicIndex + 1}<\/div>\n                <div class=\"fgs-grid\">\n                    <div class=\"fgs-field\"><label>Degree \/ Qualification<\/label><input type=\"text\" name=\"academic[${academicIndex}][degree]\"><\/div>\n                    <div class=\"fgs-field\"><label>University \/ Institution<\/label><input type=\"text\" name=\"academic[${academicIndex}][university]\"><\/div>\n                    <div class=\"fgs-field\"><label>Effective Date<\/label><input type=\"date\" name=\"academic[${academicIndex}][effective_date]\"><\/div>\n                    <div class=\"fgs-field\"><label>General \/ Special<\/label><input type=\"text\" name=\"academic[${academicIndex}][general_special]\"><\/div>\n                    <div class=\"fgs-field fgs-full\"><label>Subjects Offered<\/label><textarea name=\"academic[${academicIndex}][subjects]\"><\/textarea><\/div>\n                    <div class=\"fgs-field\"><label>Class Obtained<\/label><select name=\"academic[${academicIndex}][class_obtained]\"><option value=\"\">Select<\/option><option value=\"First Class\">First Class<\/option><option value=\"Second Class (Upper)\">Second Class (Upper)<\/option><option value=\"Second Class (Lower)\">Second Class (Lower)<\/option><option value=\"Pass\">Pass<\/option><option value=\"Other\">Other<\/option><\/select><\/div>\n                    <div class=\"fgs-field\"><label>Course Duration<\/label><input type=\"text\" name=\"academic[${academicIndex}][course_duration]\" placeholder=\"e.g. 4 years\"><\/div>\n                <\/div>`;\n            container.appendChild(row);\n            academicIndex++;\n        });\n\n        let professionalIndex = 1;\n        document.getElementById('addProfessionalRow').addEventListener('click', function () {\n            const container = document.getElementById('professionalContainer');\n            const row = document.createElement('div');\n            row.className = 'fgs-repeat professional-row';\n            row.innerHTML = `\n                <button type=\"button\" class=\"fgs-remove\">&times; Remove<\/button>\n                <div class=\"fgs-repeat-title\">Professional Qualification ${professionalIndex + 1}<\/div>\n                <div class=\"fgs-grid\">\n                    <div class=\"fgs-field\"><label>Qualification \/ Certificate<\/label><input type=\"text\" name=\"professional[${professionalIndex}][qualification]\"><\/div>\n                    <div class=\"fgs-field\"><label>Institution \/ Body<\/label><input type=\"text\" name=\"professional[${professionalIndex}][institution]\"><\/div>\n                    <div class=\"fgs-field\"><label>Effective Date<\/label><input type=\"date\" name=\"professional[${professionalIndex}][effective_date]\"><\/div>\n                    <div class=\"fgs-field\"><label>Duration \/ Level<\/label><input type=\"text\" name=\"professional[${professionalIndex}][duration]\"><\/div>\n                <\/div>`;\n            container.appendChild(row);\n            professionalIndex++;\n        });\n\n        let experienceIndex = 1;\n        document.getElementById('addExperienceRow').addEventListener('click', function () {\n            const container = document.getElementById('experienceContainer');\n            const row = document.createElement('div');\n            row.className = 'fgs-repeat experience-row';\n            row.innerHTML = `\n                <button type=\"button\" class=\"fgs-remove\">&times; Remove<\/button>\n                <div class=\"fgs-repeat-title\">Employment \/ Experience ${experienceIndex + 1}<\/div>\n                <div class=\"fgs-grid\">\n                    <div class=\"fgs-field\"><label>Designation \/ Post<\/label><input type=\"text\" name=\"experience[${experienceIndex}][designation]\"><\/div>\n                    <div class=\"fgs-field\"><label>Organization \/ Department<\/label><input type=\"text\" name=\"experience[${experienceIndex}][organization]\"><\/div>\n                    <div class=\"fgs-field\"><label>From<\/label><input type=\"date\" class=\"fgs-exp-from\" name=\"experience[${experienceIndex}][from_date]\"><\/div>\n                    <div class=\"fgs-field\"><label>To<\/label><input type=\"date\" class=\"fgs-exp-to\" name=\"experience[${experienceIndex}][to_date]\"><\/div>\n                    <div class=\"fgs-field fgs-full\"><label class=\"fgs-check-label\"><input type=\"checkbox\" class=\"fgs-exp-current\" name=\"experience[${experienceIndex}][current]\" value=\"1\"> Currently working here<\/label><\/div>\n                    <div class=\"fgs-field fgs-full\"><label>Total Experience (auto-calculated)<\/label><input type=\"text\" class=\"fgs-exp-duration\" name=\"experience[${experienceIndex}][duration]\" readonly placeholder=\"Calculated automatically from the dates\"><\/div>\n                <\/div>`;\n            container.appendChild(row);\n            fgsUpdateExperience(row);\n            experienceIndex++;\n        });\n\n        document.addEventListener('click', function (e) {\n            if (e.target && e.target.classList.contains('fgs-remove')) {\n                e.target.closest('.fgs-repeat').remove();\n            }\n        });\n\n        \/* ---------- Submit ---------- *\/\n        const fgsForm = document.getElementById('fgsApplicationForm');\n\n        fgsForm.addEventListener('reset', function () {\n            setTimeout(function () {\n                fgsToggleStudent();\n                fgsExpContainer.querySelectorAll('.experience-row').forEach(fgsUpdateExperience);\n                fgsUpdateAge(fgsPersonal);\n            }, 0);\n        });\n\n        fgsForm.addEventListener('submit', async function (e) {\n            e.preventDefault();\n            const form = this;\n            const submitBtn = document.getElementById('fgsSubmitBtn');\n            const loadingMsg = document.getElementById('fgsLoading');\n            const messageDiv = document.getElementById('fgsMessage');\n\n            messageDiv.style.display = 'none';\n\n            const fileInputs = form.querySelectorAll('input[type=\"file\"]');\n            for (let input of fileInputs) {\n                if (input.files.length > 0 && input.files[0].size > FGS_MAX_FILE_SIZE) {\n                    messageDiv.className = 'fgs-message fgs-error';\n                    messageDiv.innerText = 'One or more files exceed the 5MB size limit. Please upload smaller files.';\n                    fgsShowMessage(messageDiv);\n                    return;\n                }\n            }\n\n            submitBtn.disabled = true;\n            loadingMsg.style.display = 'block';\n\n            const formData = new FormData(form);\n            formData.append('action', 'fgs_submit_application');\n\n            try {\n                const response = await fetch(FGS_AJAX_URL, {\n                    method: 'POST',\n                    body: formData\n                });\n                const result = await response.json();\n\n                if (result.success) {\n                    const d = result.data || {};\n                    const snapshot = fgsBuildSnapshot(form);\n                    \/\/ Applicant copy: always show Age right after Date of Birth (value from the server's calculation)\n                    snapshot.forEach(function (sec) {\n                        if (sec.title !== 'Personal Details' || !d.age || !sec.groups.length) return;\n                        const rows = sec.groups[0].rows;\n                        const ai = rows.findIndex(function (r) { return r[0] === 'Age'; });\n                        if (ai >= 0) { rows[ai][1] = d.age; return; }\n                        const di = rows.findIndex(function (r) { return r[0] === 'Date of Birth'; });\n                        rows.splice(di >= 0 ? di + 1 : rows.length, 0, ['Age', d.age]);\n                    });\n                    fgsLastReceipt = {\n                        appNo: d.application_number || '',\n                        programme: d.programme || '',\n                        batch: d.batch || '',\n                        submittedAt: d.submitted_at || new Date().toLocaleString(),\n                        sections: snapshot\n                    };\n                    messageDiv.className = 'fgs-message fgs-success';\n                    messageDiv.innerHTML =\n                        '<div>' + fgsEsc(d.message || 'Application submitted successfully!') + '<\/div>' +\n                        (fgsLastReceipt.appNo ? '<div>Your Application Number: <span class=\"fgs-app-no\">' + fgsEsc(fgsLastReceipt.appNo) + '<\/span><\/div>' +\n                        '<div style=\"font-size:13px;margin-top:4px;\">Please keep this number for all future correspondence.<\/div>' : '') +\n                        '<div class=\"fgs-receipt-actions\"><button type=\"button\" class=\"fgs-print-btn\" id=\"fgsPrintBtn\">&#128424; Print \/ Save Application (PDF)<\/button><\/div>';\n                    document.getElementById('fgsPrintBtn').addEventListener('click', function () { fgsPrintReceipt(fgsLastReceipt); });\n                    form.reset();\n                } else {\n                    messageDiv.className = 'fgs-message fgs-error';\n                    messageDiv.innerText = (result.data && result.data.message) || 'An error occurred. Please try again.';\n                }\n            } catch (err) {\n                messageDiv.className = 'fgs-message fgs-error';\n                messageDiv.innerText = 'Connection error. Please try again later.';\n            } finally {\n                submitBtn.disabled = false;\n                loadingMsg.style.display = 'none';\n                fgsShowMessage(messageDiv);\n            }\n        });\n    });\n    <\/script>\n    \n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-7159","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/grad.jfn.ac.lk\/index.php?rest_route=\/wp\/v2\/pages\/7159","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/grad.jfn.ac.lk\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/grad.jfn.ac.lk\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/grad.jfn.ac.lk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/grad.jfn.ac.lk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7159"}],"version-history":[{"count":8,"href":"https:\/\/grad.jfn.ac.lk\/index.php?rest_route=\/wp\/v2\/pages\/7159\/revisions"}],"predecessor-version":[{"id":7192,"href":"https:\/\/grad.jfn.ac.lk\/index.php?rest_route=\/wp\/v2\/pages\/7159\/revisions\/7192"}],"wp:attachment":[{"href":"https:\/\/grad.jfn.ac.lk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}