/* Version: $Revision: 2576 $ */ /* "notvalue" validator */ jQuery.validator.addMethod("notvalue", function(value, element, params) { return value != params; }, jQuery.format("Please select a valid option.")); /* "validdate" validator */ jQuery.validator.addMethod('validdate',function(value, element, params) { var dob_day = params.split(',')[0]; var dob_month = params.split(',')[1]; var dob_year = params.split(',')[2]; if (($(dob_day).val() == "-1") && ($(dob_month).val() == "-1") && ($(dob_year).val() == "-1")) return true; var day = $(dob_day).val() + '' var month = $(dob_month).val() + '' if (day.length == 1) day = '0' + $(dob_day).val() if (month.length == 1) month = '0' + $(dob_month).val() completeDate = day + '/' + month + '/' + $(dob_year).val() return Date.parseExact(completeDate, "dd/MM/yyyy"); }, jQuery.format("Please enter a correct date")); /* "startenddate" validator */ jQuery.validator.addMethod('startenddate',function(value, element, params) { var start_month = params.split(',')[0]; var start_year = params.split(',')[1]; var end_month = params.split(',')[2]; var end_year = params.split(',')[3]; if ($(end_month).attr("disabled") || $(end_year).attr("disabled")) return true startDate = Date.parseExact($(start_month).val() + '/' + $(start_year).val(), "mm/yyyy"); endDate = Date.parseExact($(end_month).val() + '/' + $(end_year).val(), "mm/yyyy"); return startDate <= endDate; }, jQuery.format("End date must be later than Start Date")); /* "atleastOneSkill" validator */ jQuery.validator.addMethod("atleastOneSkill", function(value, element, param) { var skill = param.split(',')[0]; var proficiency = param.split(',')[1]; var experience = param.split(',')[2]; var lastusedmonth = param.split(',')[3]; var lastusedyear = param.split(',')[4]; var current = param.split(',')[5]; var skillCount = 0; var allComplete = true; $('[id^=skill_description]').each(function () { if ($(this).val()) { currentIndex = $(this).attr("name").split('_')[2]; if (($(proficiency+currentIndex).val() != "-1") && ($(experience+currentIndex).val() != "-1") && ((($(lastusedmonth+currentIndex).val() != "-1") && ($(lastusedyear+currentIndex).val() != "-1")) || $(current+currentIndex).attr("checked"))) { skillCount++; } else { allComplete = false; } } }); if (!allComplete) return false; else if (skillCount) return true; else return false; }, jQuery.format("Please complete all required field of the Skills section.")); /* "atleastOneLanguage" validator */ jQuery.validator.addMethod("atleastOneLanguage", function(value, element, param) { var language = param.split(',')[0]; var read = param.split(',')[1]; var write = param.split(',')[2]; var speak = param.split(',')[3]; var lastusedmonth = param.split(',')[4]; var lastusedyear = param.split(',')[5]; var current = param.split(',')[6]; var languageCount = 0; var allComplete = true; $('[id^=language_description]').each(function () { if ($(this).val() != "-1") { currentIndex = $(this).attr("name").split('_')[2]; if (($(read+currentIndex).attr("checked") || $(write+currentIndex).attr("checked") || $(speak+currentIndex).attr("checked")) && ((($(lastusedmonth+currentIndex).val() != "-1") && ($(lastusedyear+currentIndex).val() != "-1")) || $(current+currentIndex).attr("checked"))) { languageCount++; } else { allComplete = false; } } }); if (!allComplete) return false; else if (languageCount) return true; else return false; }, jQuery.format("Please complete the languages section.")); /* "condition" validator */ jQuery.validator.addMethod("condition", function(value, element, param) { switch (typeof param) { case "string": return this.optional(element) || !!$(param, element.form).length; break; case "function": return this.optional(element) || param.call(); break; } return true; }, jQuery.format("Please select a valid option.")); /* "checked" validator */ jQuery.validator.addMethod("checked", function(value, element, params) { return this.optional(element) || element.checked == params; }, jQuery.format("Please select a valid option.")); /* "alphanumeric" validator */ jQuery.validator.addMethod("alphanumeric", function(value, element, params) { return this.optional(element) || /^[a-zA-Z0-9]+$/.test($.trim(value)); }, jQuery.format("Your value many only contain letters, numbers and a dash.")); /* "name" validator */ jQuery.validator.addMethod("realname", function(value, element, params) { return this.optional(element) || /^[-a-zA-Z'üéâäàåêëèïîìÄÅÉôöòûùÖÜáíóúñÑ ]+$/.test($.trim(value)); }, jQuery.format("Your name many only contain letters and a dash.")); /* "country-code" validator */ jQuery.validator.addMethod("countrycode", function(value, element, params) { return this.optional(element) || /^\+\d{2}/.test($.trim(value)); }, jQuery.format("The Country Code is not valid.")); /* "check_startdate" validator */ jQuery.validator.addMethod("check_startdate", function(value, element, params) { var notice_period = params.split(',')[0]; var startdate = params.split(',')[1]; if ($(notice_period).val() == 4) { if (($(startdate).val() == '01/01/1900') || ($(startdate).val() == '')) { return false; } } return true; }, jQuery.format("The Start Date is not valid.")); $CareerJunction.Utils.bind_load(function () { $("#register_personaldetails").validate({ errorContainer: "#form-errors", errorLabelContainer: "#form-errors > ul", wrapper: "li", submitHandler: function(form) { $("#None").attr("disabled", true); form.submit(); }, onfocusout: false, onkeyup: false, onclick: false, rules: { mobilenumber: {minlength: 7, required: false, maxlength: 7, number: true, required: function () { return ($("#mobilecountrycode").val() != "") || ($(" #mobilecode").val() != ""); }}, terms: {required: true, checked: true}, mobilecountrycode: {minlength: 1, required: false, maxlength: 5, number: true, required: function () { return ($("#mobilenumber").val() != "") || ($(" #mobilecode").val() != ""); }}, firstname: {realname: true, minlength: 2, required: true, maxlength: 21}, mobilecode: {minlength: 2, required: false, maxlength: 3, number: true, required: function () { return ($("#mobilenumber").val() != "") || ($(" #mobilecountrycode").val() != ""); }}, lastname: {realname: true, minlength: 2, required: true, maxlength: 31}, email: {required: true, email: true} }, messages : { mobilenumber: "The third part of the Mobile Number must be 7 digits long, e.g. 1234567", terms: "You need to agree to the terms and conditions.", mobilecountrycode: "The first part of the Mobile Number must be between 1 and 5 digits long, e.g. 27", firstname: "The First Name field is required and may only contain letters and a dash (hyphen).", mobilecode: "The second part of the Mobile Number must be between 2 and 3 digits long, e.g. 82", lastname: "The Last Name field is required and may only contain letters and a dash (hyphen).", email: "Please enter a valid Email Address." } }); });