JezK
Edit File: form.js
jQuery(document).ready(function($){ window.onload = function (){ $(".bts-popup").delay(1000).addClass('is-visible'); } //open popup $('.bts-popup-trigger').on('click', function(event){ event.preventDefault(); $('.bts-popup').addClass('is-visible'); }); //close popup // $('.bts-popup').on('click', function(event){ // if( $(event.target).is('.bts-popup-button-text') || $(event.target).is('.bts-popup-button') ) { // event.preventDefault(); // $(this).removeClass('is-visible'); // } // }); // //close popup when clicking the esc keyboard button // $(document).keyup(function(event){ // if(event.which=='27'){ // $('.bts-popup').removeClass('is-visible'); // } // }); }); $( function() { $( "#dob" ).datepicker({ changeMonth: true, changeYear: true, yearRange: "-20: +0", dateFormat: "dd-mm-yy", onSelect: function() { var event; if(typeof window.Event == "function"){ event = new Event('change'); this.dispatchEvent(event); } else { event = document.createEvent('HTMLEvents'); event.initEvent('change', false, false); this.dispatchEvent(event); } } }); } ); function validateForm() { var form = document.getElementById('enquiry_form'); var email = document.getElementById('email'); var mobileFather = document.getElementById('mobileFather'); var emailValue = email.value.trim(); var mobileFatherValue = mobileFather.value.trim(); //Check Father Mobile if (/^([0|\+[0-9]{1,5})?([6-9][0-9]{9})$/.test(mobileFatherValue)) { return true; } else { alert("Invalid mobile number") mobileFather.focus() return false; } // Check Email Address if (!isEmail(emailValue)) { alert("Not a Valid Email"); return false; } else { return true; } } function isEmail(email) { return /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(email); } function validateDOB () { var dobValue = document.getElementById('dob').value.replace(/-/g, "/"); // var dobString = this.value.replace(/-/g, "/"); var gradeValue = document.getElementById('gradeApplied').value; var dobObject = new Date(dobValue); var isDobValidated; switch(gradeValue){ case "pg": //Case for PG - Play Group var minDate = new Date('10/01/2018'); var maxDate = new Date('03/30/2019'); if (dobObject.getTime() >= minDate.getTime() && dobObject.getTime() <= maxDate.getTime() ){ isDobValidated = true; } else{ alert('Date of Birth is not in the required period according to the grade selected !!'); isDobValidated = false; } break; case "nursery": //Case for nursery var minDate = new Date('10/01/2017'); var maxDate = new Date('09/30/2018'); if (dobObject.getTime() >= minDate.getTime() && dobObject.getTime() <= maxDate.getTime() ){ isDobValidated = true; } else{ alert('Date of Birth is not in the required period according to the grade selected !!'); isDobValidated = false; } break; case "lkg": //Case for lkg var minDate = new Date('10/01/2016'); var maxDate = new Date('09/30/2017'); if (dobObject.getTime() >= minDate.getTime() && dobObject.getTime() <= maxDate.getTime() ){ isDobValidated = true; } else{ alert('Date of Birth is not in the required period according to the grade selected !!'); isDobValidated = false; } break; case "hkg": //Case for hkg var minDate = new Date('10/01/2015'); var maxDate = new Date('09/30/2016'); if (dobObject.getTime() >= minDate.getTime() && dobObject.getTime() <= maxDate.getTime() ){ isDobValidated = true; } else{ alert('Date of Birth is not in the required period according to the grade selected !!'); isDobValidated = false; } break; case "1st": //Case for 1st var minDate = new Date('10/01/2014'); var maxDate = new Date('09/30/2015'); if (dobObject.getTime() >= minDate.getTime() && dobObject.getTime() <= maxDate.getTime() ){ isDobValidated = true; } else{ alert('Date of Birth is not in the required period according to the grade selected !!'); isDobValidated = false; } break; default: console.log("Default Case"); } return isDobValidated; } //Display Sibling Form Fieds based on haveSibling input function getValue(x) { if(x.value == 'No'){ document.getElementById("sibling-info-fields").style.display = 'none'; // you need a identifier for changes $('#siblingName,#siblingGrade,#siblingSchool,#siblingAge').removeAttr('required'); $('#siblingName,#siblingGrade,#siblingSchool,#siblingAge').val(""); } else{ document.getElementById("sibling-info-fields").style.display = 'block'; // you need a identifier for changes $("#siblingName,#siblingGrade,#siblingSchool,#siblingAge").prop('required',true); } } function addHighSchoolOptionTo3divs() { // Check if select has an option in it if($("#firstBranchPreference option[value='teolerHighSchool']").length === 0) { $("#firstBranchPreference").append('<option value="teolerHighSchool">Teoler High School (Sirsi)</option>'); } // Check if select has an option in it if($("#secondBranchPreference option[value='teolerHighSchool']").length === 0) { $("#secondBranchPreference").append('<option value="teolerHighSchool">Teoler High School (Sirsi)</option>'); } // Check if select has an option in it if($("#thirdBranchPreference option[value='teolerHighSchool']").length === 0) { $("#thirdBranchPreference").append('<option value="teolerHighSchool">Teoler High School (Sirsi)</option>'); } } function addPreSchoolOptionTo2divs() { // Check if select has an option in it if($("#firstBranchPreference option[value='teolerPreSchool']").length === 0) { $("#firstBranchPreference").append('<option value="teolerPreSchool">Teoler Pre School (Vaishali)</option>'); } // Check if select has an option in it if($("#secondBranchPreference option[value='teolerPreSchool']").length === 0) { $("#secondBranchPreference").append('<option value="teolerPreSchool">Teoler Pre School (Vaishali)</option>'); } } function addHighSchoolOptionTo2divs() { // Check if select has an option in it if($("#firstBranchPreference option[value='teolerHighSchool']").length === 0) { $("#firstBranchPreference").append('<option value="teolerHighSchool">Teoler High School (Sirsi)</option>'); } // Check if select has an option in it if($("#secondBranchPreference option[value='teolerHighSchool']").length === 0) { $("#secondBranchPreference").append('<option value="teolerHighSchool">Teoler High School (Sirsi)</option>'); } } function addUnboundedOptionTo2divs() { // Check if select has an option in it if($("#firstBranchPreference option[value='teolerUnbounded']").length === 0) { $("#firstBranchPreference").append('<option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option>'); } // Check if select has an option in it if($("#secondBranchPreference option[value='teolerUnbounded']").length === 0) { $("#secondBranchPreference").append('<option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option>'); } } function removePreSchoolOptionFrom2divs() { if($("#firstBranchPreference option[value='teolerPreSchool']").length > 0) { $("#firstBranchPreference option[value='teolerPreSchool']").remove(); } if($("#secondBranchPreference option[value='teolerPreSchool']").length > 0) { $("#secondBranchPreference option[value='teolerPreSchool']").remove(); } } function removeHighSchoolOptionFrom2divs() { if($("#firstBranchPreference option[value='teolerHighSchool']").length > 0) { $("#firstBranchPreference option[value='teolerHighSchool']").remove(); } if($("#secondBranchPreference option[value='teolerHighSchool']").length > 0) { $("#secondBranchPreference option[value='teolerHighSchool']").remove(); } } function removePreSchoolAndUnboundedFrom1divAndAddHighSchool() { if($("#firstBranchPreference option[value='teolerPreSchool']").length > 0) { $("#firstBranchPreference option[value='teolerPreSchool']").remove(); } if($("#firstBranchPreference option[value='teolerUnbounded']").length > 0) { $("#firstBranchPreference option[value='teolerUnbounded']").remove(); } if($("#firstBranchPreference option[value='teolerHighSchool']").length === 0) { $("#firstBranchPreference").append('<option value="teolerHighSchool">Teoler High School (Sirsi)</option>'); } } function removePreSchoolAndHighSchoolFrom1divAndAddUnbounded() { if($("#firstBranchPreference option[value='teolerPreSchool']").length > 0) { $("#firstBranchPreference option[value='teolerPreSchool']").remove(); } if($("#firstBranchPreference option[value='teolerHighSchool']").length > 0) { $("#firstBranchPreference option[value='teolerHighSchool']").remove(); } if($("#firstBranchPreference option[value='teolerUnbounded']").length === 0) { $("#firstBranchPreference").append('<option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option>'); } } $('#assessmenttype').on('change',function(){ var selected = $(this).val(); switch(selected){ case "offline": // $('.dateSelectDiv').css('display', 'flex'); $('.offline-test-msg').css('display', 'block'); $('.online-test-msg').css('display', 'none'); break; case "online": // $('.dateSelectDiv').css('display', 'none'); $('.offline-test-msg').css('display', 'none'); $('.online-test-msg').css('display', 'block'); break; } }); $("#firstBranchPreference").on("change", function() { $("#secondBranchPreference option").prop('disabled', false); $("#thirdBranchPreference option").prop('disabled', false); $("#secondBranchPreference option[value='"+this.value+"']").prop('disabled', true); $("#thirdBranchPreference option[value='"+this.value+"']").prop('disabled', true); }); $("#secondBranchPreference").on("change", function() { $("#thirdBranchPreference option").prop('disabled', false); if(this.value!='notApplicable'){ $("#thirdBranchPreference option[value='"+this.value+"']").prop('disabled', true); } var firstBranch = $('#firstBranchPreference').find(":selected").val(); $("#thirdBranchPreference option[value='"+firstBranch+"']").prop('disabled', true); //alert(firstBranch); }); $('#gradeApplied').on('change',function(){ var selection = $(this).val(); switch(selection){ case "pg": $(".secondBranchDiv").hide(); $(".thirdBranchDiv").hide(); $('#subjectChosenDiv').css('display', 'none'); //$('#assessmentTypeDiv').css('display', 'none'); $("#firstBranchPreference").html('<option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option>'); //$("#secondBranchPreference").html('<option value="">Select Preference</option><option value="teolerPreSchool">Teoler Pre School (Vaishali)</option><option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option><option value="notApplicable">Not Applicable</option>'); break; case "nursery": $(".secondBranchDiv").show(); $(".thirdBranchDiv").show(); $('#subjectChosenDiv').css('display', 'none'); //$('#assessmentTypeDiv').css('display', 'none'); $("#firstBranchPreference").html('<option value="">Select Preference</option><option value="teolerHighSchool">Teoler High School (Sirsi)</option><option value="teolerPreSchool">Teoler Pre School (Vaishali)</option><option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option>'); $("#secondBranchPreference").html('<option value="">Select Preference</option><option value="teolerHighSchool">Teoler High School (Sirsi)</option><option value="teolerPreSchool">Teoler Pre School (Vaishali)</option><option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option><option value="notApplicable">Not Applicable</option>'); $("#thirdBranchPreference").html('<option value="">Select Preference</option><option value="teolerHighSchool">Teoler High School (Sirsi)</option><option value="teolerPreSchool">Teoler Pre School (Vaishali)</option><option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option><option value="notApplicable">Not Applicable</option>'); break; case "lkg": $(".secondBranchDiv").hide(); $(".thirdBranchDiv").hide(); $('#subjectChosenDiv').css('display', 'none'); //$('#assessmentTypeDiv').css('display', 'none'); $("#firstBranchPreference").html('<option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option>'); /* $("#firstBranchPreference").html('<option value="">Select Preference</option><option value="teolerHighSchool">Teoler High School (Sirsi)</option><option value="teolerPreSchool">Teoler Pre School (Vaishali)</option><option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option>'); $("#secondBranchPreference").html('<option value="">Select Preference</option><option value="teolerHighSchool">Teoler High School (Sirsi)</option><option value="teolerPreSchool">Teoler Pre School (Vaishali)</option><option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option><option value="notApplicable">Not Applicable</option>'); $("#thirdBranchPreference").html('<option value="">Select Preference</option><option value="teolerHighSchool">Teoler High School (Sirsi)</option><option value="teolerPreSchool">Teoler Pre School (Vaishali)</option><option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option><option value="notApplicable">Not Applicable</option>'); */ break; case "hkg": $(".secondBranchDiv").show(); $(".thirdBranchDiv").show(); $('#subjectChosenDiv').css('display', 'none'); //$('#assessmentTypeDiv').css('display', 'none'); $("#firstBranchPreference").html('<option value="">Select Preference</option><option value="teolerHighSchool">Teoler High School (Sirsi)</option><option value="teolerPreSchool">Teoler Pre School (Vaishali)</option><option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option>'); $("#secondBranchPreference").html('<option value="">Select Preference</option><option value="teolerHighSchool">Teoler High School (Sirsi)</option><option value="teolerPreSchool">Teoler Pre School (Vaishali)</option><option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option><option value="notApplicable">Not Applicable</option>'); $("#thirdBranchPreference").html('<option value="">Select Preference</option><option value="teolerHighSchool">Teoler High School (Sirsi)</option><option value="teolerPreSchool">Teoler Pre School (Vaishali)</option><option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option><option value="notApplicable">Not Applicable</option>'); break; case "1st": $(".secondBranchDiv").hide(); $(".thirdBranchDiv").hide(); $('#subjectChosenDiv').css('display', 'none'); //$('#assessmentTypeDiv').css('display', 'none'); $("#firstBranchPreference").html('<option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option>'); //$("#firstBranchPreference").html('<option value="">Select Preference</option><option value="teolerHighSchool">Teoler High School (Sirsi)</option><option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option>'); //$("#secondBranchPreference").html('<option value="">Select Preference</option><option value="teolerHighSchool">Teoler High School (Sirsi)</option><option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option><option value="notApplicable">Not Applicable</option>'); break; case "2nd": $(".secondBranchDiv").show(); $(".thirdBranchDiv").hide(); $('#subjectChosenDiv').css('display', 'none'); //$('#assessmentTypeDiv').css('display', 'none'); $("#firstBranchPreference").html('<option value="">Select Preference</option><option value="teolerHighSchool">Teoler High School (Sirsi)</option><option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option>'); $("#secondBranchPreference").html('<option value="">Select Preference</option><option value="teolerHighSchool">Teoler High School (Sirsi)</option><option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option><option value="notApplicable">Not Applicable</option>'); break; case "3rd": $(".secondBranchDiv").show(); $(".thirdBranchDiv").hide(); $('#subjectChosenDiv').css('display', 'none'); //$('#assessmentTypeDiv').css('display', 'none'); $("#firstBranchPreference").html('<option value="">Select Preference</option><option value="teolerHighSchool">Teoler High School (Sirsi)</option><option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option>'); $("#secondBranchPreference").html('<option value="">Select Preference</option><option value="teolerHighSchool">Teoler High School (Sirsi)</option><option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option><option value="notApplicable">Not Applicable</option>'); break; case "4th": $(".secondBranchDiv").show(); $(".thirdBranchDiv").hide(); $('#subjectChosenDiv').css('display', 'none'); //$('#assessmentTypeDiv').css('display', 'none'); $("#firstBranchPreference").html('<option value="">Select Preference</option><option value="teolerHighSchool">Teoler High School (Sirsi)</option><option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option>'); $("#secondBranchPreference").html('<option value="">Select Preference</option><option value="teolerHighSchool">Teoler High School (Sirsi)</option><option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option><option value="notApplicable">Not Applicable</option>'); break; case "5th": $(".secondBranchDiv").show(); $(".thirdBranchDiv").hide(); $('#subjectChosenDiv').css('display', 'none'); //$('#assessmentTypeDiv').css('display', 'none'); $("#firstBranchPreference").html('<option value="">Select Preference</option><option value="teolerHighSchool">Teoler High School (Sirsi)</option><option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option>'); $("#secondBranchPreference").html('<option value="">Select Preference</option><option value="teolerHighSchool">Teoler High School (Sirsi)</option><option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option><option value="notApplicable">Not Applicable</option>'); break; case "6th": $(".secondBranchDiv").show(); $(".thirdBranchDiv").hide(); $('#subjectChosenDiv').css('display', 'none'); //$('#assessmentTypeDiv').css('display', 'flex'); $("#firstBranchPreference").html('<option value="">Select Preference</option><option value="teolerHighSchool">Teoler High School (Sirsi)</option><option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option>'); $("#secondBranchPreference").html('<option value="">Select Preference</option><option value="teolerHighSchool">Teoler High School (Sirsi)</option><option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option><option value="notApplicable">Not Applicable</option>'); break; case "7th": $(".secondBranchDiv").show(); $(".thirdBranchDiv").hide(); $('#subjectChosenDiv').css('display', 'none'); //$('#assessmentTypeDiv').css('display', 'flex'); $("#firstBranchPreference").html('<option value="">Select Preference</option><option value="teolerHighSchool">Teoler High School (Sirsi)</option><option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option>'); $("#secondBranchPreference").html('<option value="">Select Preference</option><option value="teolerHighSchool">Teoler High School (Sirsi)</option><option value="teolerUnbounded">Teoler Unbounded (Sirsi)</option><option value="notApplicable">Not Applicable</option>'); break; case "8th": $(".secondBranchDiv").hide(); $(".thirdBranchDiv").hide(); $('#subjectChosenDiv').css('display', 'none'); //$('#assessmentTypeDiv').css('display', 'flex'); $("#firstBranchPreference").html('<option value="teolerHighSchool">Teoler High School (Sirsi)</option>'); break; case "9th": $(".secondBranchDiv").hide(); $(".thirdBranchDiv").hide(); $('#subjectChosenDiv').css('display', 'flex'); $("#subjectChosen").html('<option value="IX_NTSE">9th NTSE Integrated Program</option>'); //$('#assessmentTypeDiv').css('display', 'flex'); $("#firstBranchPreference").html('<option value="teolerHighSchool">Teoler High School (Sirsi)</option>'); break; case "10th": $(".secondBranchDiv").hide(); $(".thirdBranchDiv").hide(); $('#subjectChosenDiv').css('display', 'none'); //$('#assessmentTypeDiv').css('display', 'flex'); $("#firstBranchPreference").html('<option value="teolerHighSchool">Teoler High School (Sirsi)</option>'); break; case "11th": $(".secondBranchDiv").hide(); $(".thirdBranchDiv").hide(); $('#subjectChosenDiv').css('display', 'flex'); //$('#assessmentTypeDiv').css('display', 'flex'); $("#subjectChosen").html('<option value="XI_IPMAT">11th IPMAT Integrated Program</option><option value="XI_JEE">11th JEE Integrated Program</option><option value="XI_NEET">11th NEET Integrated Program </option><option value="XI_Commerce" selected>11th Commerce</option><option value="XI_Science_PCM">11th Science (PCM)</option><option value="XI_Science_PCB">11th Science (PCB)</option>'); $("#firstBranchPreference").html('<option value="teolerHighSchool">Teoler High School (Sirsi)</option>'); break; case "12th": $(".secondBranchDiv").hide(); $(".thirdBranchDiv").hide(); $('#subjectChosenDiv').css('display', 'flex'); $("#subjectChosen").html('<option value="XII_Commerce">12th Commerce</option><option value="XII_Science_PCM">12th Science (PCM)</option><option value="XII_Science_PCB">12th Science (PCB)</option>'); //$('#assessmentTypeDiv').css('display', 'flex'); $("#firstBranchPreference").html('<option value="teolerHighSchool">Teoler High School (Sirsi)</option>'); break; default: $("#otherType").hide() } }); $('#subjectChosen').on('change',function(){ var subjectValue = $(this).val(); if (subjectValue=="XI_IPMAT" || subjectValue=="XI_JEE" || subjectValue=="XI_NEET") { $("#assessmenttype").html('<option value="offline" selected>Offline Interaction (Fee for this mode is INR 250/-)</option>'); } else { $("#assessmenttype").html('<option value="offline" selected>Offline Interaction (Fee for this mode is INR 250/-)</option>'); } }); $('#gradeApplied').on('change',function(){ var gradeApplied = $(this).val(); if (gradeApplied!="11th") { $("#assessmenttype").html('<option value="offline" selected>Offline Interaction (Fee for this mode is INR 250/-)</option>'); } });