var xmlhttp; function GetXmlHttpObject() { if (window.XMLHttpRequest) return new XMLHttpRequest(); if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP"); alert("Your browser does not support AJAX!"); return; }; $(document).ready(function () { $.fn.validateLead = function () { if ($('#First_Name').val() == '') { alert("Please enter your First Name"); $('#First_Name').focus(); return false; } else if ($('#First_Name').val() != '') { if (/[^A-Za-z\d]/.test($('#First_Name').val())) { alert("Special Characters and Space are not allowed in First Name"); $('#First_Name').focus(); return false; } } if ($('#Last_Name').val() == "") { alert("Please enter your Last Name"); $('#Last_Name').focus(); return false; } else if ($('#Last_Name').val() != '') { if (/[^A-Za-z\d]/.test($('#Last_Name').val())) { alert("Special Characters are not allowed in Last Name"); $('#Last_Name').focus(); return false; } } if ($('#EmailId').val() == "") { alert("Please enter your E-Mail ID"); $('#EmailId').focus(); return false; } else if ($("#EmailId").val() != "") { var x = $('#EmailId').val(); var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if (!filter.test(x)) { alert("Enter a valid E-Mail ID"); $('#EmailId').focus(); return false; } } if ($("#LiveState").val() == "0" || $("#LiveState").val() == "") { alert("Please select your State of Residence"); return false; } else if ($("#LiveCity").val() == "0" || $("#LiveCity").val() == "") { alert("Please select your City of Residence"); return false; } else if ($('#Phone_Number').val() == "") { alert("Please enter your Mobile Number"); $('#Phone_Number').focus(); return false; } else if ($('#Phone_Number').val().length != 10) { alert("Please enter a valid Mobile Number"); $('#Phone_Number').focus(); return false; } else if ($('#StudyIn').val() == "") { alert("Please enter your preferred for Studies"); $('#StudyIn').focus(); return false; } //else if ($("#StudyState").val() == "0") { // alert("Please select your preferred state for Studies"); // return false; //} else if ($("#Educationlevel").val() == "0") { alert("Please select your Highest Level of Education"); return false; } else if ($("#preference").val() == "0") { alert("Please select your Study Preference"); return false; } else if ($("#AreaOfInterest").val() == "0") { alert("Please select an option for What do you want to study?"); return false; } else if (!validateRadios()) { alert("Are you looking for an Education Loan? Please select one."); return false; } else if ($("#EnterCaptchaImg").val() == "") { alert("Please enter captcha"); $('#EnterCaptchaImg').focus(); return false; } else { $('#Submit').disabled = true; $('.LoaderBack').show(); $.post("/Leads", getModel(), function (data) { if ($.isNumeric(data)) { if (data == "0") { CustomAlertModal('Alert', 'danger', "Oops! There seems to be some error. Please try again"); } else { CustomAlertModal('Thank you for submitting your information', 'success', "
We will try to connect you with the best Institutes from your desired location.
"); $('#EnqcityDiv').html(''); $('.studentenquiryform :input').each(function () { if ($(this).is('select')) { $(this).val(''); } else { $(this).val(this.defaultValue); } }); } } else { CustomAlertModal('Alert', 'info', "Enter valid letters shown in the image below"); $('#CaptchaImg').attr('src', "/globalajax/ajax/CaptchaImage?add=false&d=" + Math.random()); } $('.LoaderBack').hide(); $('#Submit').disabled = false; }); } } function getModel() { var Model = { "FName": $("#First_Name").val(), "LName": $("#Last_Name").val(), "Email": $("#EmailId").val(), //"LiveState": $("#LiveState").val(), "LiveState": $('[data-id="LiveState"]').val(), "LiveCity": $("#LiveCity").val(), "PhoneNumber": $("#Phone_Number").val(), //"Want_Study": $("#StudyState").val(), "StudyIn": $("#StudyIn").val(), "ELevel": $("#Educationlevel").val(), "Preference": $("#preference").val(), "Interest": $("#AreaOfInterest").val(), "Loan": $("input[type='radio']:checked").val(), "StudyIn": $("#StudyIn").val(), "OtherCity": $("#EnqOther_City_Name").val(), "Captcha": $("#EnterCaptchaImg").val(), }; return Model; } $.fn.isNumberKey = function (evt) { var charCode = (evt.which) ? evt.which : event.keyCode; if (charCode > 31 && (charCode < 48 || charCode > 57)) return false; else return true; }; $(document).on("click", "#GetCaptcha", function () { $('#CaptchaImg').attr('src', "/globalajax/ajax/CaptchaImage?add=false&d=" + Math.random()); }); }); function GetEnqCityData(StateId) { jQuery('.citystateLoading').show(); $.ajax({ url: '/globalajax/Leads/GetCityData', data: { name: "LiveCity", stateid: StateId.length > 0 ? StateId : 0, type: 1,fuctioncall:"GetCitySelectFunction" }, type: 'GET', contentType: "application/json; charset=utf-8", beforeSend: function () { //jQuery('.citystateLoading').show('disabled', 'disabled'); //jQuery('.SentMailLoading').removeAttr('style'); }, success: function (data) { $('#EnqcityDiv').html(''); if (data) { $('#EnqcityDiv').append(data); } else { $('#EnqcityDiv').append(''); //CustomAlertModal('Alert', 'danger', "Oops! There seems to be some error. Please try again"); } }, error: function (req, status, error) { CustomAlertModal('Alert', 'danger', "We've encountered an error. Please try again later."); } }).always(function () { setTimeout(function () { jQuery('.citystateLoading').hide() }, 1000); }); } function GetCitySelectFunction(value) { if (value == "Other") { $("#enqothercityDiv").show(); } else { $("#enqothercityDiv").hide(); } } function validateRadios() { var opts = document.getElementsByName("Loan"); var Status = 0; for (var i = 0; i < opts.length; i++) { if (opts.item(i).checked) { Status = 1; } } if (Status == "1") return true else return false; };