var txtValue; var _count = 0; function load() { $(".chzn-select").chosen(); $(".chzn-select-deselect").chosen({ allow_single_deselect: true }); } function loadScript() { //<%=floatingInputGrid.ClientID %> jqOld("#floatingInputGrid").autocomplete({ source: function (request, responce) { var tr = extractLast(request.term); if (tr.length >= 2) { $.ajax({ //url: '<%= ResolveUrl("CurrentOpportunity.aspx/GetDataForFreeTextSearch") %>', url: "CurrentOpportunity.aspx/GetDataForFreeTextSearch", type: "POST", contentType: "application/json;charset=utf-8", data: "{'term':'" + tr + "'}", dataType: 'json', success: function (data) { if (data.d.length > 0) { //responce(data.d.slice(0, 30)); responce(data.d); } else { //responce([{ label: 'The entered keyword does not match any available jobs.', val: 0 }]); //alert('Skill not found'); //jqOld("#floatingInputGrid") = ''; alert('Entered skill not available.'); let str = jqOld("#floatingInputGrid").val(); str = str.substr(0, str.lastIndexOf(',') + 1); jqOld("#floatingInputGrid").val(str); } }, error: function (err) { alert(err); } }); } }, focus: function () { // prevent value inserted on focus return false; }, select: function (event, ui) { var terms = split(this.value); // remove the current input terms.pop(); // add the selected item terms.push(ui.item.value); // add placeholder to get the comma-and-space at the end terms.push(""); this.value = terms.join(", "); return false; } }) //$("#floatingInputGrid").bind("keydown", function (event) { // if (event.keyCode === $.ui.keyCode.TAB && // $(this).data("autocomplete").menu.active) { // event.preventDefault(); // } //}) function split(val) { return val.split(/,\s*/); } function extractLast(term) { return split(term).pop(); } } function loadSkills() { jqOld("#txtSkills").autocomplete({ source: function (request, responce) { var tr = extractLast(request.term); if (tr.length >= 2) { $.ajax({ url: "BuddyReferal.aspx/GetSkill", type: "POST", contentType: "application/json;charset=utf-8", data: "{'prefixText':'" + tr + "'}", dataType: 'json', success: function (data) { if (data.d.length > 0) { //responce(data.d.slice(0, 30)); responce(data.d); } else { //responce([{ label: 'The entered keyword does not match any available jobs.', val: 0 }]); alert('Entered skill not available.'); let str = jqOld("#txtSkills").val(); str = str.substr(0, str.lastIndexOf(',') + 1); jqOld("#txtSkills").val(str); } }, error: function (err) { alert(err); } }); } }, focus: function () { // prevent value inserted on focus return false; }, select: function (event, ui) { var terms = split(this.value); // remove the current input terms.pop(); // add the selected item terms.push(ui.item.value); // add placeholder to get the comma-and-space at the end terms.push(""); this.value = terms.join(", "); return false; } }) function split(val) { return val.split(/,\s*/); } function extractLast(term) { return split(term).pop(); } } function loadSkillsCareerApplyPage() { jqOld("#txtSkills").autocomplete({ source: function (request, responce) { var tr = extractLast(request.term); if (tr.length >= 2) { $.ajax({ url: "Career_apply_job_signup.aspx/GetSkill", type: "POST", contentType: "application/json;charset=utf-8", data: "{'prefixText':'" + tr + "'}", dataType: 'json', success: function (data) { if (data.d.length > 0) { //responce(data.d.slice(0, 30)); responce(data.d); //const splitString = jqOld("#txtSkills").val().split(','); //for (let i = 0; i <= splitString.length - 1; i++) { // _count++; //} //if (_count >= 5) { // alert('2 skills'); // return; //} } else { //responce([{ label: 'The entered keyword does not match any available jobs.', val: 0 }]); alert('Entered skill not available.'); let str = jqOld("#txtSkills").val(); str = str.substr(0, str.lastIndexOf(',') + 1); jqOld("#txtSkills").val(str); } }, error: function (err) { alert(err); } }); } }, focus: function () { // prevent value inserted on focus return false; }, select: function (event, ui) { var terms = split(this.value); // remove the current input terms.pop(); // add the selected item terms.push(ui.item.value); // add placeholder to get the comma-and-space at the end terms.push(""); this.value = terms.join(", "); return false; } }) function split(val) { return val.split(/,\s*/); } function extractLast(term) { return split(term).pop(); } } function ValidateSkillCount() { var _count = 0; let originalString = jqOld("#txtSkills").val(); const splitString = originalString.split(','); for (let i = 0; i <= splitString.Length - 1; i++) { _count++; } if(_count >= 2) { alert('2 skills'); return; } } var jqOld = jQuery.noConflict(); jqOld(document).ready(loadScript); Sys.WebForms.PageRequestManager.getInstance().add_endRequest(loadScript); var jqOldSkills = jQuery.noConflict(); jqOld(document).ready(loadSkills); Sys.WebForms.PageRequestManager.getInstance().add_endRequest(loadSkills); var jqOldSkillsCareerApply = jQuery.noConflict(); jqOld(document).ready(loadSkillsCareerApplyPage); Sys.WebForms.PageRequestManager.getInstance().add_endRequest(loadSkillsCareerApplyPage);