$(document).ready(function() { checkall('contact-check-all', 'contact-chkbox'); $('#input-search').on('keyup', function() { var rex = new RegExp($(this).val(), 'i'); $('.searchable-items .items:not(.items-header-section)').hide(); $('.searchable-items .items:not(.items-header-section)').filter(function() { return rex.test($(this).text()); }).show(); }); $('.view-grid').on('click', function(event) { event.preventDefault(); /* Act on the event */ $(this).parents('.switch').find('.view-list').removeClass('active-view'); $(this).addClass('active-view'); $(this).parents('.searchable-container').removeClass('list'); $(this).parents('.searchable-container').addClass('grid'); $(this).parents('.searchable-container').find('.searchable-items').removeClass('list'); $(this).parents('.searchable-container').find('.searchable-items').addClass('grid'); }); $('.view-list').on('click', function(event) { event.preventDefault(); /* Act on the event */ $(this).parents('.switch').find('.view-grid').removeClass('active-view'); $(this).addClass('active-view'); $(this).parents('.searchable-container').removeClass('grid'); $(this).parents('.searchable-container').addClass('list'); $(this).parents('.searchable-container').find('.searchable-items').removeClass('grid'); $(this).parents('.searchable-container').find('.searchable-items').addClass('list'); }); $('#btn-add-contact').on('click', function(event) { $('#addContactModal #btn-add').show(); $('#addContactModal #btn-edit').hide(); $('#addContactModal').modal('show'); }) function deleteContact() { $(".delete").on('click', function(event) { event.preventDefault(); /* Act on the event */ $(this).parents('.items').remove(); }); } function addContact() { $("#btn-add").click(function() { var getParent = $(this).parents('.modal-content'); var $_name = getParent.find('#c-name'); var $_email = getParent.find('#c-email'); var $_occupation = getParent.find('#c-occupation'); var $_phone = getParent.find('#c-phone'); var $_location = getParent.find('#c-location'); var $_getValidationField = document.getElementsByClassName('validation-text'); var reg = /^.+@[^\.].*\.[a-z]{2,}$/; var phoneReg = /^\d*\.?\d*$/; var $_nameValue = $_name.val(); var $_emailValue = $_email.val(); var $_occupationValue = $_occupation.val(); var $_phoneValue = $_phone.val(); var $_locationValue = $_location.val(); if ($_nameValue == "") { $_getValidationField[0].innerHTML = 'Name must be filled out'; $_getValidationField[0].style.display = 'block'; } else { $_getValidationField[0].style.display = 'none'; } if ($_emailValue == "") { $_getValidationField[1].innerHTML = 'Email Id must be filled out'; $_getValidationField[1].style.display = 'block'; } else if((reg.test($_emailValue) == false)) { $_getValidationField[1].innerHTML = 'Invalid Email'; $_getValidationField[1].style.display = 'block'; } else { $_getValidationField[1].style.display = 'none'; } if ($_phoneValue == "") { $_getValidationField[2].innerHTML = 'Invalid (Enter 10 Digits)'; $_getValidationField[2].style.display = 'block'; } else if((phoneReg.test($_phoneValue) == false)) { $_getValidationField[2].innerHTML = 'Please Enter A numeric value'; $_getValidationField[2].style.display = 'block'; } else { $_getValidationField[2].style.display = 'none'; } if ($_nameValue == "" || $_emailValue == "" || (reg.test($_emailValue) == false) || $_phoneValue == "" || (phoneReg.test($_phoneValue) == false)) { return false; } $html = '
Email:
' + ''+ $_emailValue +'
' + 'Location:
' + ''+ $_locationValue +'
' + 'Phone:
' + ''+ $_phoneValue +'
' + '