//today's date var today = new Date(); var todayYYYYMMDD = '20100908'; //var currentYr = today.getFullYear();//format yyyy var currentYr = 2010; var qualType = new Array('txtQualificationType', 'txtQualificationType1', 'txtQualificationType2'); var qualCountry = new Array('txtQualificationCountry', 'txtQualificationCountry1', 'txtQualificationCountry2'); var qualProvinceTR = new Array('qualificationProvince', 'qualificationProvince1', 'qualificationProvince2'); var qualProvince = new Array('txtProvince', 'txtProvince1', 'txtProvince2'); var qualAB = new Array('txtNameofAwardingBody', 'txtNameofAwardingBody1', 'txtNameofAwardingBody2'); var qualABName = new Array('University1', 'University2', 'University3'); var qualCA = new Array('txtCollege', 'txtCollege1', 'txtCollege2'); var qualCATR = new Array('trCollegeAttended', 'trCollegeAttended1', 'trCollegeAttended2'); var qualCAName = new Array('College1', 'College2', 'College3'); var qualMode = new Array('txtModeofStudy', 'txtModeofStudy1', 'txtModeofStudy2'); var enrollmentMonth = new Array('enrollmentMonthQ1', 'enrollmentMonthQ2', 'enrollmentMonthQ3'); var enrollmentYear = new Array('enrollmentYearQ1', 'enrollmentYearQ2', 'enrollmentYearQ3'); var graduationMonth = new Array('graduationMonthQ1', 'graduationMonthQ2', 'graduationMonthQ3'); var qualYear = new Array('txtyear', 'txtyear1', 'txtyear2'); var qualFaculty = new Array('txtFacultyofStudy', 'txtFacultyofStudy1', 'txtFacultyofStudy2'); var qualFacultyOther = new Array('otherFaculty', 'otherFaculty1', 'otherFaculty2'); var qualSpecialization = new Array('txtSpecializationofStudy', 'txtSpecializationofStudy1', 'txtSpecializationofStudy2'); var errorNameEmpty = 'Please enter a valid Name'; var errorDateEmpty = 'Please enter your Date of Birth'; var errorPOBDefault = 'Please select your Place of Birth'; var errorDateInvalid = 'Please enter a valid date'; var errorDateFuture = 'Please enter a date earlier than today'; var errorDOBlaterThanAwardingYear ='Date of Birth cannot be later than date of qualification awarding year'; var errorDOBlaterThanPeriodOfStudy ='Date of Birth cannot be later than the period of study'; var errorDOBlaterThanSMV ='Date of Birth cannot be later than Skilled Migrant Visa issued year'; var errorGenderEmpty = 'Please select a Gender'; var errorNationalityDefault = 'Please select a Nationality'; var errorTravelEmpty = 'Please enter your Passport Number'; var errorTravelAlphaNumeric = 'Travel Document/Passport Number can only contain alphanumeric characters'; var errorMailAddress1Empty = 'Please enter your Mailing Address'; var errorMailingCountryDefault = 'Please select a Mailing Country'; var errorResidenceCountryDefault = 'Please select a Country of Residence'; var errorEpecEmpty = 'Please select if you were previously an EPEC holder'; var errorWorkInSgEmpty = 'Please select if you have worked in Singapore before'; var errorPrSgEmpty = 'Please select if you were previously a Singapore Citizen or Singapore Permanent Resident'; var errorEmailEmpty = 'Please enter a valid Email Address'; var errorContactNumberCountryCodeEmpty = 'Please enter a Country Code'; var errorContactNumberEmpty = 'Please enter your Contact Number'; var errorContactNumberCountryCodeInvalid = 'Please enter a valid Country Code'; var errorContactNumberInvalid = 'Please enter a valid Contact Number'; var errorNricEmpty = 'Please enter your NRIC number'; var errorWorkExEmpty = 'Please choose whether you have any full-time working experience'; var errorLastIndustryDefault = 'Please select Last Profession Type of Industry'; var errorLastIndustryEmpty = 'Please enter Last Profession Type of Industry'; var errorJobTitleEmpty = 'Please enter Job Title'; var errorSkilledVisaEmpty = 'Please choose whether you have any Skilled Migrant Visa'; var errorSkilledVisaTypeDefault = 'Please select Skilled Migrant Visa Type'; var errorSkilledVisaTypeEmpty = 'Please enter Skilled Migrant Visa Type'; var errorIssueYrEmpty = 'Please enter Skilled Migrant Visa Year of Issue'; var errorQualificationTypeDefault = 'Please select a Qualification Type'; var errorQualificationCountryDefault = 'Please select Qualification Country'; var errorQualificationProvinceDefault = 'Please select Qualification Province'; var errorAwardingBodyDefault = 'Please select Name of Awarding Body'; var errorAwardingBodyEmpty = 'Please enter Name of Awarding Body'; var errorCollegeAttendedDefault = 'Please select College Attended'; var errorCollegeAttendedEmpty = 'Please enter College Attended'; var errorYearEmpty = 'Please enter valid Period of Study'; var errorYearDefault = 'Please enter valid Period of Study'; var errorYearInvalid = 'Please enter a valid year (between year 1900 and current year)'; var errorYearMonthInvalid = 'Please enter a valid year and month (between Jan 1900 and current month)'; var errorFromYearMonthLaterToYearMonth = '"From" Date cannot be later than "To" Date'; var errorModeDefault = 'Please select a Mode of Study'; var errorFacultyDefault = 'Please select Faculty of Study'; var errorFacultyEmpty = 'Please enter Faculty of Study'; var errorSpecializationDefault = 'Please select Specialization of Study'; var errorSpecializationEmpty = 'Please enter Specialization of Study'; var Alphabet; Alphabet =/^[A-Za-z ]+$/; // var ValidDate; // ValidDate = "/^((0[1-9]|[12][0-9]|3[01])[/](0[1-9]|1[012])[/](?:19|20)\d\d)$/"; var ValidEmail; ValidEmail=/\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))*/; var Numeric; Numeric = /^[0-9]+$/; var AlphaNumeric; AlphaNumeric = /^[A-Za-z0-9 ]+$/; function emailcheck(emailValue) { if (emailValue == null || emailValue == "") return false; var at="@"; var dot="."; var lat=emailValue.indexOf(at); var lstr=emailValue.length; var ldot=emailValue.indexOf(dot); if (emailValue.indexOf(at)==-1){ return false; } if (emailValue.indexOf(at)==-1 || emailValue.indexOf(at)==0 || emailValue.indexOf(at)==lstr){ return false; } if (emailValue.indexOf(dot)==-1 || emailValue.indexOf(dot)==0 || emailValue.indexOf(dot)==lstr){ return false; } if (emailValue.indexOf(at,(lat+1))!=-1){ return false; } if (emailValue.substring(lat-1,lat)==dot || emailValue.substring(lat+1,lat+2)==dot){ return false; } if (emailValue.indexOf(dot,(lat+2))==-1){ return false; } if (emailValue.indexOf(" ")!=-1){ return false; } return true; } function resetErrorMsgs(){ //particulars resetErrorMsg('MsgName'); resetErrorMsg('MsgDOB'); resetErrorMsg('MsgPOB'); resetErrorMsg('MsgGender'); resetErrorMsg('MsgNationality'); resetErrorMsg('MsgTravel'); resetErrorMsg('MsgMailAddress1'); resetErrorMsg('MsgMailingCountry'); resetErrorMsg('MsgCountryofResidence'); resetErrorMsg('Msgepecbefore'); //previous work in sg resetErrorMsg('MsgworkInSG'); resetErrorMsg('Msgfin'); //previous sg citizen resetErrorMsg('MsgprSG'); resetErrorMsg('MsgNRIC'); //particulars resetErrorMsg('Msgemail'); resetErrorMsg('Msgcontactnumber'); //qualification 1 resetErrorMsg('Msgqualificationtype'); resetErrorMsg('MsgQualificationCountry'); resetErrorMsg('Msg1stProvince'); resetErrorMsg('MsgNameofAwardingBody'); resetErrorMsg('MsgCollegeAttended'); resetErrorMsg('Msgyear'); resetErrorMsg('MsgModeofStudy'); resetErrorMsg('MsgFacultyofStudy'); resetErrorMsg('MsgSpecializationofStudy'); //qualification 2 resetErrorMsg('MsgQualificationtype1'); resetErrorMsg('MsgQualificationCountry1'); resetErrorMsg('Msg2ndProvince'); resetErrorMsg('MsgNameofAwardingBody1'); resetErrorMsg('MsgCollegeAttended1'); resetErrorMsg('Msgyear1'); resetErrorMsg('MsgModeofStudy1'); resetErrorMsg('MsgFacultyofStudy1'); resetErrorMsg('MsgSpecializationofStudy1'); //qualification 3 resetErrorMsg('MsgQualificationtype2'); resetErrorMsg('MsgQualificationCountry2'); resetErrorMsg('Msg3rdProvince'); resetErrorMsg('MsgNameofAwardingBody2'); resetErrorMsg('MsgCollegeAttended2'); resetErrorMsg('Msgyear2'); resetErrorMsg('MsgModeofStudy2'); resetErrorMsg('MsgFacultyofStudy2'); resetErrorMsg('MsgSpecializationofStudy2'); //previous work experience resetErrorMsg('Msgworkex'); resetErrorMsg('MsgLastprofessionTypeOfIndustry'); resetErrorMsg('MsgLastprofessionTypeOfIndustry1'); resetErrorMsg('Msgjobtitle'); //skilled visa resetErrorMsg('Msgskilledvisa'); resetErrorMsg('MsgSkilledVisaType'); resetErrorMsg('MsgSkilledVisaTypeName'); resetErrorMsg('Msgissueyr'); } function setErrorMsg(elementName, errorMsg){ var element = document.getElementById(elementName); if (element){ element.innerText = errorMsg; element.textContent = errorMsg; } } var dobDate = new Date(); var dobDateYYYYMMDD = ''; var isInputValid = true; var blnCheck = true; function validateInput() { blnCheck = true; resetErrorMsgs(); /****************************************************************************/ /************************** CHECK FOR EMPTY FIELDS **************************/ /****************************************************************************/ // Name Validation var name = trim(document.getElementById('txtName').value); if (name.search(Alphabet) == -1) { if (blnCheck) { document.getElementById('txtName').focus(); } blnCheck = false; setErrorMsg('MsgName', errorNameEmpty); } // Date Validation // Date Validation var date = trim(document.getElementById('txtDOBdd').value); var mth = trim(document.getElementById('txtDOBmm').value); var yr = trim(document.getElementById('txtDOByyyy').value); dobDateYYYYMMDD = yr.toString()+mth.toString()+date.toString(); if (date == ''){ if (blnCheck) { document.getElementById('txtDOBdd').focus(); } blnCheck = false; document.getElementById('MsgDOB').innerText = 'Please enter your Date of Birth'; document.getElementById('MsgDOB').textContent = 'Please enter your Date of Birth'; } else { if (mth == ''){ if (blnCheck) { document.getElementById('txtDOBmm').focus(); } blnCheck = false; document.getElementById('MsgDOB').innerText = 'Please enter your Date of Birth'; document.getElementById('MsgDOB').textContent = 'Please enter your Date of Birth'; } else { if (yr == ''){ if (blnCheck) { document.getElementById('txtDOByyyy').focus(); } blnCheck = false; document.getElementById('MsgDOB').innerText = 'Please enter your Date of Birth'; document.getElementById('MsgDOB').textContent = 'Please enter your Date of Birth'; } else { dobDate.setFullYear(yr, mth-1, date); if ((date != dobDate.getDate())||(mth-1 != dobDate.getMonth())||(yr != dobDate.getFullYear()) || yr < 1900){ if (blnCheck) { document.getElementById('txtDOBdd').focus(); } blnCheck = false; document.getElementById('MsgDOB').innerText = 'Please enter a valid date'; document.getElementById('MsgDOB').textContent = 'Please enter a valid date'; } else { //check that dob NOT > today if (dobDateYYYYMMDD>todayYYYYMMDD){ if (blnCheck) { document.getElementById('txtDOBdd').focus(); } document.getElementById('MsgDOB').innerText = 'Your Date of Birth cannot be later than the current date'; document.getElementById('MsgDOB').textContent = 'Your Date of Birth cannot be later than the current date'; blnCheck = false; } } } } } // Place of Birth var PlaceOfBirth = trim(document.getElementById('txtPOB').value); if (PlaceOfBirth == -1) { if (blnCheck) { document.getElementById('txtPOB').focus(); } blnCheck = false; setErrorMsg('MsgPOB', errorPOBDefault); } // Gender var gender = getSelectedRadio(document.form1.txtgender); if (gender == -1) { if (blnCheck) { document.getElementById('txtgender').focus(); } blnCheck = false; setErrorMsg('MsgGender', errorGenderEmpty); } // Nationality var nationality = document.getElementById('NationalityID').value; if (nationality == -1) { if (blnCheck) { document.getElementById('NationalityID').focus(); } blnCheck = false; setErrorMsg('MsgNationality', errorNationalityDefault); } // Travel document var traveldocument = trim(document.getElementById('txttraveldocument').value); if (traveldocument == '' ) { if (blnCheck) { document.getElementById('txttraveldocument').focus(); } blnCheck = false; setErrorMsg('MsgTravel', errorTravelEmpty); } else if (traveldocument.search(AlphaNumeric) == -1) { if (blnCheck) { document.getElementById('txttraveldocument').focus(); } blnCheck = false; setErrorMsg('MsgTravel', errorTravelAlphaNumeric); document.getElementById('txttraveldocument').focus(); } // Mailing Address var MailingAddress = trim(document.getElementById('txtMailAddress1').value); if (MailingAddress == '') { if (blnCheck) { document.getElementById('txtMailAddress1').focus(); } blnCheck = false; setErrorMsg('MsgMailAddress1', errorMailAddress1Empty); } // Mailing Country var MailingCountry = trim(document.getElementById('MailingCountry').value); if (MailingCountry == -1) { if (blnCheck) { document.getElementById('MailingCountry').focus(); } blnCheck = false; setErrorMsg('MsgMailingCountry', errorMailingCountryDefault); } //Country of Residence var txtCountryofResidence = trim(document.getElementById('CountryofResidence').value); if (txtCountryofResidence == -1) { if (blnCheck) { document.getElementById('CountryofResidence').focus(); } blnCheck = false; setErrorMsg('MsgCountryofResidence', errorResidenceCountryDefault); } // EPEC var epecbefore = getSelectedRadio(document.form1.txtepecbefore); if (epecbefore == -1) { if (blnCheck) { document.getElementById('txtepecbefore').focus(); } blnCheck = false; setErrorMsg('Msgepecbefore', errorEpecEmpty); } // work in Singapore var workInSG = getSelectedRadio(document.form1.txtworkInSG); if (workInSG == -1) { if (blnCheck) { document.getElementById('txtworkInSG').focus(); } blnCheck = false; setErrorMsg('MsgworkInSG', errorWorkInSgEmpty); } // Singapore PR var prSG = getSelectedRadio(document.form1.txtprSG); if (prSG == -1) { if (blnCheck) { document.getElementById('txtprSG').focus(); } blnCheck = false; setErrorMsg('MsgprSG', errorPrSgEmpty); } /****************************************************************************/ /***************************** CHECK NRIC EMPTY *****************************/ /****************************************************************************/ var nric = ''; if (prSG == 0){ nric = trim(document.getElementById('txtNRIC').value); if (nric == ''){ if (blnCheck) { document.getElementById('txtNRIC').focus(); } blnCheck = false; setErrorMsg('MsgNRIC', errorNricEmpty); } } // eEmail var eMail = trim(document.getElementById('txtemail').value); if (emailcheck(eMail) == false) { if (blnCheck) { document.getElementById('txtemail').focus(); } setErrorMsg('Msgemail', errorEmailEmpty); blnCheck = false; } // contact number var precontactnumber = trim(document.getElementById('txtpre').value); var contactnumber = trim(document.getElementById('txtcontactnumber').value); if (precontactnumber == ''){ if (blnCheck) { document.getElementById('txtpre').focus(); } setErrorMsg('Msgcontactnumber', errorContactNumberCountryCodeEmpty); blnCheck = false; } else { if (contactnumber == ''){ if (blnCheck) { document.getElementById('txtcontactnumber').focus(); } setErrorMsg('Msgcontactnumber', errorContactNumberEmpty); blnCheck = false; } else { if (precontactnumber.search(Numeric) == -1){ if (blnCheck) { document.getElementById('txtpre').focus(); } setErrorMsg('Msgcontactnumber', errorContactNumberCountryCodeInvalid); blnCheck = false; } else { if (contactnumber.search(Numeric) == -1){ if (blnCheck) { document.getElementById('txtcontactnumber').focus(); } setErrorMsg('Msgcontactnumber', errorContactNumberInvalid); blnCheck = false; } } } } isInputValid = blnCheck; var qualification1 = chkQualification(0); blnCheck = qualification1; var t2ndcheck = getSelectedCheckbox(document.form1.txt2ndchk); var qualification2 = true; if (t2ndcheck.length != 0) { qualification2 = chkQualification(1); blnCheck = qualification2; } var t3rdcheck = getSelectedCheckbox(document.form1.txt3rdchk); var qualification3 = true; if (t3rdcheck.length != 0) { qualification3 = chkQualification(2); blnCheck = qualification3; } /****************************************************************************/ /************************* CHECK WORKING EXPERIENCE *************************/ /****************************************************************************/ // working experience // var workex = getSelectedRadio(document.form1.txtworkex); // if (workex == -1) { // blnCheck = false; // setErrorMsg('Msgworkex', errorWorkExEmpty); // } // // if (workex == 0){ // var LastprofessionTypeOfIndustry = document.getElementById('txtLastprofessionTypeOfIndustry').value; // if (LastprofessionTypeOfIndustry == -1) { // setErrorMsg('MsgLastprofessionTypeOfIndustry', errorLastIndustryDefault); // blnCheck = false; // } else if (LastprofessionTypeOfIndustry == '-') { // var otherInd = trim(document.getElementById('othersPro').value); // if (otherInd == ''){ // setErrorMsg('MsgLastprofessionTypeOfIndustry1', errorLastIndustryEmpty); // blnCheck = false; // } // } // // var jobtitle = trim(document.getElementById('txtjobtitle').value); // if (jobtitle == '') { // setErrorMsg('Msgjobtitle', errorJobTitleEmpty); // blnCheck = false; // } // } /****************************************************************************/ /**************************** CHECK SKILLED VISA ****************************/ /****************************************************************************/ // skilled visa var visa = getSelectedRadio(document.form1.txtskilledvisa); if (visa == -1) { if (blnCheck) { document.getElementById('txtskilledvisa').focus(); } blnCheck = false; setErrorMsg('Msgskilledvisa', errorSkilledVisaEmpty); } if (visa == 0){ var visaType = document.getElementById('txtSkilledVisaType').value; if (visaType == -1) { if (blnCheck) { document.getElementById('txtSkilledVisaType').focus(); } setErrorMsg('MsgSkilledVisaType', errorSkilledVisaTypeDefault); blnCheck = false; } else if (visaType == '-') { var otherVisa = trim(document.getElementById('otherVisa').value); if (otherVisa == ''){ if (blnCheck) { document.getElementById('otherVisa').focus(); } setErrorMsg('MsgSkilledVisaTypeName', errorSkilledVisaTypeEmpty); blnCheck = false; } } var issueyr = trim(document.getElementById('txtissueyr').value); if (issueyr == '') { if (blnCheck) { document.getElementById('txtissueyr').focus(); } setErrorMsg('Msgissueyr', errorIssueYrEmpty); blnCheck = false; } else { issueyr = valYear(issueyr) if (issueyr == -1) { if (blnCheck) { document.getElementById('txtissueyr').focus(); } blnCheck = false; setErrorMsg('Msgissueyr', errorYearInvalid); } else { if (dobDate.getFullYear() > issueyr) { if (blnCheck) { document.getElementById('txtDOByyyy').focus(); } document.getElementById('MsgDOB').innerText = errorDOBlaterThanSMV; document.getElementById('MsgDOB').textContent = errorDOBlaterThanSMV; blnCheck = false; } } } } if ((blnCheck == true) && (qualification1 == true) && (qualification2 == true) && (qualification3 == true)) { return true; } else { alert('Incomplete or invalid data entered! \nPlease verify and try again.'); return false; } } /****************************************************************************/ /*************************** CHECK QUALIFICATION ****************************/ /****************************************************************************/ function chkQualification(type){ var msgQualType = new Array('Msgqualificationtype', 'Msgqualificationtype1', 'Msgqualificationtype2'); var msgQualCountry = new Array('MsgQualificationCountry', 'MsgQualificationCountry1', 'MsgQualificationCountry2'); var msgQualProvince = new Array('Msg1stProvince', 'Msg2ndProvince', 'Msg3rdProvince'); var msgQualAB = new Array('MsgNameofAwardingBody', 'MsgNameofAwardingBody1', 'MsgNameofAwardingBody2'); var msgQualCA = new Array('MsgCollegeAttended', 'MsgCollegeAttended1', 'MsgCollegeAttended2'); var msgQualMode = new Array('MsgModeofStudy', 'MsgModeofStudy1', 'MsgModeofStudy2'); var msgQualYear = new Array('Msgyear', 'Msgyear1', 'Msgyear2'); var msgQualFaculty = new Array('MsgFacultyofStudy', 'MsgFacultyofStudy1', 'MsgFacultyofStudy2'); var msgQualSpecialization = new Array('MsgSpecializationofStudy', 'MsgSpecializationofStudy1', 'MsgSpecializationofStudy2'); //qualification Country var txtQualificationCountry = document.getElementById(qualCountry[type]).value; if (txtQualificationCountry == -1) { if (blnCheck) { document.getElementById(qualCountry[type]).focus(); } setErrorMsg(msgQualCountry[type], errorQualificationCountryDefault); blnCheck = false; } //qualification Province if (document.getElementById(qualProvince[type])){ if (document.getElementById(qualProvinceTR[type]).style.display == ''){ var txtProvince = document.getElementById(qualProvince[type]).value; if (txtProvince == -1){ if (blnCheck) { document.getElementById(qualProvince[type]).focus(); } setErrorMsg(msgQualProvince[type], errorQualificationProvinceDefault); blnCheck = false; } } } // Qualification Type var qualificationtype = document.getElementById(qualType[type]).value; if (qualificationtype == -1) { if (blnCheck) { document.getElementById(qualType[type]).focus(); } setErrorMsg(msgQualType[type], errorQualificationTypeDefault); blnCheck = false; } //awarding body var NameofAwardingBody = document.getElementById(qualAB[type]).value; if (NameofAwardingBody == -1) { if (blnCheck) { document.getElementById(qualAB[type]).focus(); } setErrorMsg(msgQualAB[type], errorAwardingBodyDefault); blnCheck = false; } else if (NameofAwardingBody == '-'){ var uni = trim(document.getElementById(qualABName[type]).value); if (uni == ''){ if (blnCheck) { document.getElementById(qualABName[type]).focus(); } setErrorMsg(msgQualAB[type], errorAwardingBodyEmpty); blnCheck = false; } } //college attended if (document.getElementById(qualCA[type])) { if (document.getElementById(qualCATR[type]).style.display == ''){ var collegeAttended = document.getElementById(qualCA[type]).value; if (collegeAttended == -1) { if (blnCheck) { document.getElementById(qualCA[type]).focus(); } setErrorMsg(msgQualCA[type], errorCollegeAttendedDefault); blnCheck = false; } else if (collegeAttended == '-'){ var coll = trim(document.getElementById(qualCAName[type]).value); if (coll == ''){ if (blnCheck && isInputValid) { document.getElementById(qualCAName[type]).focus(); } setErrorMsg(msgQualCA[type], errorCollegeAttendedEmpty); blnCheck = false; } } } } //faculty var FacultyofStudy = document.getElementById(qualFaculty[type]).value; if (FacultyofStudy == -1) { if (blnCheck) { document.getElementById(qualFaculty[type]).focus(); } setErrorMsg(msgQualFaculty[type], errorFacultyDefault); blnCheck = false; } else if (SpecializationofStudy == '-'){ var otherFac = trim(document.getElementById(qualFacultyOther[type]).value); if (otherFac == ''){ if (blnCheck) { document.getElementById(qualFacultyOther[type]).focus(); } setErrorMsg(msgQualFaculty[type], errorFacultyEmpty); blnCheck = false; } } //specialization var SpecializationofStudy = document.getElementById(qualSpecialization[type]).value; if (SpecializationofStudy == -1) { if (blnCheck) { document.getElementById(qualSpecialization[type]).focus(); } setErrorMsg(msgQualSpecialization[type], errorSpecializationDefault); blnCheck = false; } //period of study var tenrollmentMonth = trim(document.getElementById(enrollmentMonth[type]).value); var tenrollmentYear = trim(document.getElementById(enrollmentYear[type]).value); var tgraduationMonth = trim(document.getElementById(graduationMonth[type]).value); var tgraduationYear = trim(document.getElementById(qualYear[type]).value); if (tenrollmentMonth== '' || tenrollmentYear == '' || tgraduationMonth == '' || tgraduationYear == '') { if (tenrollmentMonth == '') { if (blnCheck) { document.getElementById(enrollmentMonth[type]).focus(); } blnCheck = false; } if (tenrollmentYear == '') { if (blnCheck) { document.getElementById(enrollmentYear[type]).focus(); } blnCheck = false; } if (tgraduationMonth == '') { if (blnCheck) { document.getElementById(graduationMonth[type]).focus(); } blnCheck = false; } if (tgraduationYear == '') { if (blnCheck) { document.getElementById(graduationMonth[type]).focus(); } blnCheck = false; } setErrorMsg(msgQualYear[type], errorYearEmpty); } else { if (tenrollmentYear.search(Numeric) == -1 || tgraduationYear.search(Numeric) == -1){ if (blnCheck) { document.getElementById(enrollmentYear[type]).focus(); } blnCheck = false; setErrorMsg(msgQualYear[type], errorYearDefault); } else { tenrollmentYear = valYear(tenrollmentYear) tgraduationYear = valYear(tgraduationYear) if (tenrollmentYear == -1 || tgraduationYear == -1) { if (blnCheck) { document.getElementById(enrollmentYear[type]).focus(); } blnCheck = false; setErrorMsg(msgQualYear[type], errorYearMonthInvalid); } else { //var enrollmentDate = new Date(); //var graduationDate = new Date(); //enrollmentDate.setFullYear(tenrollmentYear, tenrollmentMonth-1, 1); //graduationDate.setFullYear(tgraduationYear, tgraduationMonth-1, 1); var enrollmentDateYYYYMMDD = tenrollmentYear.toString() + tenrollmentMonth.toString() + '01'; var graduationDateYYYYMMDD = tgraduationYear.toString() + tgraduationMonth.toString() + '01'; if (enrollmentDateYYYYMMDD>todayYYYYMMDD || graduationDateYYYYMMDD>todayYYYYMMDD){ if (blnCheck) { document.getElementById(msgQualYear[type]).focus(); } blnCheck = false; setErrorMsg(msgQualYear[type], errorYearMonthInvalid); } else { if (enrollmentDateYYYYMMDD > graduationDateYYYYMMDD) { if (blnCheck) { document.getElementById(msgQualYear[type]).focus(); } blnCheck = false; setErrorMsg(msgQualYear[type], errorFromYearMonthLaterToYearMonth); } else { if (dobDateYYYYMMDD > enrollmentDateYYYYMMDD) { if (blnCheck) { document.getElementById('txtDOByyyy').focus(); } document.getElementById('MsgDOB').innerText = errorDOBlaterThanPeriodOfStudy; document.getElementById('MsgDOB').textContent = errorDOBlaterThanPeriodOfStudy; blnCheck = false; } } } } } } //mode of study var ModeofStudy = trim(document.getElementById(qualMode[type]).value); if (ModeofStudy == -1) { if (blnCheck && isInputValid) { document.getElementById(qualMode[type]).focus(); } setErrorMsg(msgQualMode[type], errorModeDefault); blnCheck = false; } return blnCheck; } function getCheckedValue(radioObj) { if(!radioObj) return ""; var radioLength = radioObj.length; if(radioLength == undefined) if(radioObj.checked) return radioObj.value; else return ""; for(var i = 0; i < radioLength; i++) { if(radioObj[i].checked) { return radioObj[i].value; } } return ""; } function valYear(t) { var y=parseInt(t); if(!((y>=1900) && (y<=currentYr)) ) { return -1; } else { return y; } } function hideshow(checkbox, obj) { var tobj = document.getElementById(obj); // alert(checkbox.checked); if (checkbox.checked == true) { tobj.style.display = ''; } else { tobj.style.display = 'none'; } } function resetErrorMsg(obj) { if (document.getElementById(obj)){ document.getElementById(obj).innerText = ' '; document.getElementById(obj).textContent = ' '; } } function setCheckedValue(radioObj, newValue) { try { if(!radioObj) return; var radioLength = radioObj.length; if(radioLength == undefined) { radioObj.checked = (radioObj.value == newValue.toString()); return; } for(var i = 0; i < radioLength; i++) { radioObj[i].checked = false; if(radioObj[i].value == newValue.toString()) { radioObj[i].checked = true; } } } catch(err) {} } function setSelectedValue(radioObj, newValue) { if(!radioObj) return; var radioLength = radioObj.length; if(radioLength == undefined) { radioObj.Selected = (radioObj.value == newValue.toString()); return; } for(var i = 0; i < radioLength; i++) { radioObj[i].checked = false; if(radioObj[i].value == newValue.toString()) { radioObj[i].selectedIndex = i; } } } function getSelectedRadio(buttonGroup) { // returns the array number of the selected radio button or -1 if no button is selected if (buttonGroup[0]) { // if the button group is an array (one button is not an array) for (var i=0; i