$(function () {
$('#ZipCode').val('');
$('#PassingYear').val('');
$('#PassingYear').bind('blur', function () {
var a = $('#PassingYear').val();
if (a.length > 0 && a.length < 4) {
alert('Enter the Year in 4 digits like 2001');
$('#PassingYear').focus();
}
else { }
});
function HideAll() {
$('#LastNamemsg').hide();
$('#Emailmsg').hide();
$('#CountryIdmsg').hide();
$('#Statemsg').hide();
$('#Citymsg').hide();
$('#AlmaMater').hide();
$('#ProfileDetail').hide();
}
function IsEmail(email) {
var reg = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
return reg.test(email);
}
function IsNumeric(nmbr) {
return !(nmbr.search(/[^0-9\-()+,]/g) != -1);
}
function v(ele, msg) {
if ($(ele).val() == '' || $(ele).val() == null)
$(msg).show();
else
$(msg).hide();
}
function IsSpecialChar(ele) {
if (/[^A-Za-z\d]/.test($(ele).val())) {
return true;
}
else
return false;
}
$.fn.CharsOnly = function (evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if ((charCode == 32) || (charCode == 44)) return true;
else if (((charCode >= 65) && (charCode <= 90)) || ((charCode >= 97) && (charCode <= 122))) return true;
else return false;
};
$.fn.Subject = function (evt, idval) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
if (AlphaNum(idval) == true) return false;
else return true;
}
else if ((charCode == 32) || (charCode == 44)) return true;
else if (((charCode >= 65) && (charCode <= 90)) || ((charCode >= 97) && (charCode <= 122))) return true;
else return false;
};
$.fn.isNumberKey = function (evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
else
return true;
};
$.fn.CheckEventSpace = function (evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode == 8)
return true;
else if ((charCode >= 65) && (charCode <= 90))
return true;
else if ((charCode >= 97) && (charCode <= 122))
return true;
else
return false;
};
var countit = 1;
$.fn.State = function (evt, idval) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode == 38) {
if (checkand(idval) == true) return false;
else return true;
}
else if ((charCode == 32))
return true;
else if ((charCode >= 65) && (charCode <= 90)) return true;
else if ((charCode >= 97) && (charCode <= 122)) return true;
else return false;
};
$.fn.Almameter = function (evt, idval) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode == 38) {
if (checkand(idval) == true) return false;
else return true;
}
else if ((charCode == 32))
return true;
else if ((charCode >= 65) && (charCode <= 90)) return true;
else if ((charCode >= 97) && (charCode <= 122)) return true;
else return false;
};
$.fn.Working = function (evt, idval) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode == 38) {
if (checkand(idval) == true) return false;
else return true;
}
else if ((charCode == 32))
return true;
else if ((charCode >= 65) && (charCode <= 90)) return true;
else if ((charCode >= 97) && (charCode <= 122)) return true;
else return false;
};
$.fn.City = function (evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if ((charCode >= 65) && (charCode <= 90)) return true;
else if ((charCode >= 97) && (charCode <= 122)) return true;
else return false;
};
function checkand(id) {
var add = document.getElementById(id).value;
var patt1 = /[&&]/gi;
var it = patt1.test(add);
return it;
}
function AlphaNum(id) {
var add = document.getElementById(id).value;
var patt1 = /[a-zA-Z0-9]/;
var it = patt1.test(add);
return it;
}
$.fn.CheckAddress = function (evt, idval) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode == 38) {
if (checkand(idval) == true) return false;
else return true;
}
else if ((charCode == 32) || (charCode == 40) || (charCode == 41) || (charCode == 44) || (charCode == 47))
return true;
else if (((charCode >= 48) && (charCode <= 57)) || ((charCode >= 65) && (charCode <= 90)) || ((charCode >= 97) && (charCode <= 122)))
return true;
else return false;
};
$.fn.CheckEventOther = function (evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode == 38)
return true;
else if ((charCode == 32))
return true;
else if ((charCode >= 48) && (charCode <= 57))
return true;
else if ((charCode >= 65) && (charCode <= 90))
return true;
else if ((charCode >= 97) && (charCode <= 122))
return true;
else return false;
};
$.fn.CheckEventMail = function (evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode == 32)
return false;
else
return true;
};
$.fn.CheckEventNum = function (evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if ((charCode > 47) && (charCode < 58))
return false;
else
return true;
};
function RemoveSpaces(ele) {
var val = $(ele).val();
$(ele).val(val.replace(/\s{2,}/g, ' ').trim());
}
// $('#FirstName').bind('keyup', function () { v('#FirstName', '#FirstNamemsg'); });
// $('#FirstName').bind('blur', function () {
// v('#FirstName', '#FirstNamemsg');
// if (IsSpecialChar('#FirstName')) {
// alert("No Special Characters Are Allowed in First Name");
// return false;
// }
// });
// $('#LastName').bind('keyup', function () { v('#LastName', '#LastNamemsg'); });
// $('#LastName').bind('blur', function () {
// v('#LastName', '#LastNamemsg');
// if (IsSpecialChar('#LastName')) {
// alert("No Special Characters Are Allowed in Last Name");
// return false;
// }
// });
// $('#Email').bind('keyup', function () { v('#Email', '#Emailmsg'); });
$('#Email').bind('blur', function () {
// v('#Email', '#Emailmsg');
if ($('#Email').val().length != 0) {
if (!IsEmail($('#Email').val()))
alert('Please enter valid Email id');
}
});
// $('#CountryId').bind('blur keyup', function () { if ($('#CountryId').val() == 0) $('#CountryIdmsg').show(); else $('#CountryIdmsg').hide(); });
// $('#State').bind('blur', function () { RemoveSpaces('#State'); });
// $('#City').bind('blur keyup', function () { v('#City', '#Citymsg'); });
// $('#AlmaMater').bind('blur keyup', function () { v('#AlmaMater', '#AlmaMatermsg'); });
// $('#ProfileDetail').bind('blur keyup', function () { v('#ProfileDetail', '#ProfileDetailmsg'); });
//$('#RegisterBtn').click(function (e) { e.PreventDefault(); if (Validate()) $('#Accountfrm').submit(); });
$('#RegisterBtn').click(function (e) {
e.preventDefault();
if ($('#FirstName').val() == '') {
alert('First Name is Required');
$('#FirstName').focus();
return false;
}
else {
if (IsSpecialChar('#FirstName')) {
alert('No Special Characters are Allowed in First Name');
return false;
}
if ($('#LastName').val() == '') {
alert('Last Name is Required');
$('#LastName').focus();
return false;
}
else {
if (IsSpecialChar('#LastName')) {
alert('No Special Characters are Allowed in Last Name');
return false;
}
if ($('#Email').val() == '') {
alert('Email id is Required');
$('#Email').focus();
return false;
}
else {
if (!IsEmail($('#Email').val())) {
alert('Please enter valid Email id');
$('#Email').focus();
return false;
}
else {
if ($('#CountryId').val() == 0) {
alert('Country is Required');
$('#CountryId').focus();
return false;
}
else {
if ($('#stateddl').val() === '' || $('#stateddl').val() === '0') {
alert('State is Required');
$('#stateddl').focus();
return false;
}
else {
if ($('#cityddl').val() === '' || $('#cityddl').val() === '0') {
alert('City is Required');
$('#cityddl').focus();
return false;
}
else {
if ($('#Nationality').val() == '') {
alert('Nationality is Required');
$('#Nationality').focus();
return false;
}
if ($('#AlmaMater').val() == '') {
alert('Alma Mater is Required');
$('#AlmaMater').focus();
return false;
}
else {
if ($('#ProfileDetail').val() == '') {
alert('Brief Profile Description is Required');
$('#ProfileDetail').focus();
return false;
}
else {
//var challange = Recaptcha.get_challenge();
//var response = Recaptcha.get_response();
//if (response == '') {
// alert('Please enter Captcha value!');
// return false;
//}
//var url = CUrl() + "Scripts/XmlHttpReq.aspx?fun=validatecaptcha&challenge=" + challange + "&response=" + response;
//xmlhttp = GetXmlHttpObject();
//xmlhttp.open("GET", url, true);
//xmlhttp.onreadystatechange = GetReCaptchaResponse;
//xmlhttp.send(null);
//return false;
if (MyCaptchaResponse()) {
document.getElementById('Accountfrm').submit();
return true;
}
}
}
}
}
}
}
}
}
}
});
$('#Address1').bind('blur', function () { RemoveSpaces('#Address1'); });
$('#Address2').bind('blur', function () { RemoveSpaces('#Address2'); });
$('#State').bind('blur', function () { RemoveSpaces('#State'); });
$('#City').bind('blur', function () { RemoveSpaces('#City'); });
$('#Education').bind('blur', function () { RemoveSpaces('#Education'); });
$('#Subject').bind('blur', function () { RemoveSpaces('#Subject'); });
$('#AlmaMater').bind('blur', function () { RemoveSpaces('#AlmaMater'); });
$('#JobProfile ').bind('blur', function () { RemoveSpaces('#JobProfile'); });
$('#ProfileDetail ').bind('blur', function () { RemoveSpaces('#ProfileDetail'); });
$('#OtherInfo').bind('blur', function () { RemoveSpaces('#OtherInfo'); });
$('#CounsellorDetail ').bind('blur', function () { RemoveSpaces('#CounsellorDetail '); });
function GetReCaptchaResponse() {
if (xmlhttp.readyState == 4) {
if (xmlhttp.responseText == 'false') {
alert('Please Enter Correct Captcha!');
Recaptcha.reload();
return false;
}
else if (xmlhttp.responseText == 'true') {
$('#Experience').val($('#YearList').val() + '.' + $('#MonthList').val());
$('#CountryName').val($("#CountryId option:selected").text());
document.getElementById('Accountfrm').submit();
return true;
}
}
else {
return false;
}
};
$('#CountryId').change(function () {
$('#Nationality').val($("#CountryId option:selected").text());
});
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;
};
function CUrl() {
var url = document.domain;
if (url == "localhost") {
url = "https://localhost:2937/";
}
else {
url = "https://" + document.domain + "/";
}
return url;
}
/// get cities of a state
$(document).on('change', '#stateddl', function () {
$('.register-loader-layer').show();
var cityObj = $('#cityddl');
$('#State').val($('#stateddl option:selected').text());
var stateid = $(this).val();
if (stateid === '0') {
$('#eduloader').hide();
$('#citysection').hide();
cityObj.html = '';
return false;
}
else {
//alert(CUrl() + 'globalajax/localajax/GetCities?stateid=' + stateid)
$.ajax({
url: CUrl() + 'globalajax/localajax/GetCities?stateid=' + stateid,
type: 'get',
contentType: 'application/json',
success: function (data) {
//console.log(data.citydata)
setTimeout(function () { $('.register-loader-layer').hide(); }, 100);
$('#cityddl').empty();
var citylist = data.citydata;
var html = '';;
$('#cityddl').append(html);
for (var x = 0; x < citylist.length; x++) {
var cityname = citylist[x].CityName;
var cityid = citylist[x].CityId;
html = '';
$('#cityddl').append(html);
}
$('#citysection').show();
},
error: function () {
$('.register-loader-layer').hide();
alerts('Something went wrong!');
}
})
}
});
$(document).on('change', '#cityddl', function () {
$('#City').val($('#cityddl option:selected').text());
});;
});