JezK
Edit File: functions.js
function readURL(input,id) { if (input.files && input.files[0]) { var reader = new FileReader(); reader.onload = function(e) { $('#'+id).attr('src', e.target.result); } reader.readAsDataURL(input.files[0]); } } function addbusiness() { var fuData = document.getElementById('profilePicture'); var FileUploadPath = fuData.value; if (FileUploadPath == '' && ($('#action').val()=='addbusiness' || $('#action').val() =='addprofessional')) { alert("Please upload an image"); return false } else { var phoneno = /^\d{5,15}$/; var email=$('#email').val(); var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; var Extension = FileUploadPath.substring(FileUploadPath.lastIndexOf('.') + 1).toLowerCase(); if (Extension != "png" && Extension != "jpeg" && Extension != "jpg" && FileUploadPath!='') { alert("Please upload png or jpg images"); return false; } else if($('#business_name').val()=='' && $('#action').val()!='addprofessional') { alert("Please enter Business Name");return false; } else if($('#action').val()!='addprofessional' && $('#action').val()!='editProfessional' && ($('#business_name').val()).length<=3) { alert("Business Name must be more than 3 characters");return false; } else if($('#professionalname').val()=='' && ($('#action').val()=='addbusiness' || $('#action').val()=='addprofessional' || $('#action').val()=='editProfessional')) { alert("Please enter Professional Name");return false; } else if($('#profession').val()=='') { alert("Please enter Profession");return false; } else if($('#specialization').val()=='' && ($('#action').val()=='addbusiness' ||$('#action').val()=='addprofessional' || $('#action').val() =='editProfessional')) { alert("Please enter Specialization");return false; } else if($('#categories').val()=='') { alert("Please select categories");return false; } else if($('#country').val()=='' && ($('#action').val()=='addbusiness' || $('#action').val()=='addprofessional' || $('#action').val()=='editProfessional')) { alert("Please select country");return false; } else if($('#state').val()=='' && ($('#action').val()=='addbusiness' || $('#action').val()=='addprofessional' || $('#action').val()=='editProfessional')) { alert("Please select State");return false; } else if($('#cities').val()=='' && ($('#action').val()=='addbusiness'|| $('#action').val()=='addprofessional' || $('#action').val()=='editProfessional')) { alert("Please select city");return false; } else if($('#mobile').val()=='') { alert("Please enter Mobile Number");return false; } else if(!$('#mobile').val().match(phoneno)) { alert("Please enter valid Mobile Number");return false; } else if($('#username').val()=='') { alert("Please enter Username");return false; } else if(($('#username').val()).length<=3) { alert("Username must be more than 3 characters");return false; } else if($('#plan_type').val()=='') { alert("Please select plan");return false; } else if($('#owner').val()=='') { alert("Please enter Owner");return false; } else if(email=='') { alert("Please enter Email");return false; } else if (reg.test(email) == false) { alert("Please enter valid email address");return false; } else if($('#location').val()=='' && ($('#action').val()=='addbusiness' || $('#action').val()=='addprofessional')) { alert("Please enter Location");return false; } else if($('#password').val()=='' && ($('#action').val()=='addbusiness'|| $('#action').val()=='addprofessional' || $('#action').val() !='editProfessional')) { alert("Please enter Password");return false; } else if(($('#password').val()).length<=5 && ($('#action').val()=='addbusiness' || $('#action').val()=='addprofessional')) { alert("Password must be more than five characters");return false; } /* else if($('input[id="agree"]:checked').val()!='1' && ($('#action').val()!='addbusiness' || $('#action').val()!='addprofessional')) { alert("Please select the terms and conditions");return false; } */ else if($('#about').val()=='' && ($('#action').val()=='addbusiness' || $('#action').val()=='addprofessional' || $('#action').val()=='editProfessional')) { alert("Please enter About");return false; } } } function categoryValidations() { var fuData = document.getElementById('catimage'); var FileUploadPath = fuData.value; if (FileUploadPath == '' && $('#action').val()=='addcategory') { alert("Please upload an image"); return false } else { var Extension = FileUploadPath.substring(FileUploadPath.lastIndexOf('.') + 1).toLowerCase(); if (Extension != "png" && Extension != "jpeg" && Extension != "jpg" && FileUploadPath!='') { alert("Please upload png or jpg images"); return false; } if($('#catname').val()=='') { alert("Please enter category name");return false; } } } function addCountry() { if($('#countryname').val()=='') { alert("Please enter country name");return false; } } function addPercentage() { if($('#percentage').val()=='') { alert("Please enter percentage ");return false; } } function blockorunblock(status,id,aid) { let statusmsg='Blocked'; let statusText = 'block'; if(status==0) { statusmsg='Unblocked' statusText = 'unblock'; } if(confirm('Are you sure want to '+statusText+' the business?')) { var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { if(this.responseText==1) { let mystatus=0; let changetext="Unblock"; if(status==0) { changetext="Block"; mystatus=1; } //$('#'+aid).text(statusmsg); document.getElementById("blockid"+aid).innerHTML=changetext; document.getElementById("blockid"+aid).setAttribute("onClick", "blockorunblock("+mystatus+",'"+id+"',"+aid+");"); alert('Successfully '+statusmsg); }else{ alert("Status updation was failed"); } return false; } } xmlhttp.open("POST", "ajax.php?action=blkunblkBusiness&bid="+id+"&status="+status, true); xmlhttp.send(); } else{ return false; } } $(".toggle-password").click(function() { $(this).toggleClass("showHide"); var input = $($(this).attr("toggle")); if (input.attr("type") == "password") { input.attr("type", "text"); document.getElementById("show").innerHTML = "Hide"; } else { input.attr("type", "password"); document.getElementById("show").innerHTML = "Show"; } }); function deleteall(typeofdel) { if(confirm('Are you sure want to delete')) { var testval = []; $('.checkmark:checked').each(function() { testval.push($(this).val()); }); if(testval.length<=0) { alert('Please select atleast one record to delete'); return false; }else{ document.getElementById(typeofdel).submit(); } }else{ return false; } }