Server IP : 51.89.169.208 / Your IP : 18.216.230.65 Web Server : Apache System : Linux ns3209505.ip-198-244-202.eu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Tue Nov 5 04:50:16 EST 2024 x86_64 User : yellowleaf ( 1019) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/yellowleaf/public_html/members/ |
Upload File : |
<?php $path = $_SERVER['DOCUMENT_ROOT']; include_once $path . '/connect_db.php'; include 'accesscontrol.php'; header('Content-Type: text/html; charset=utf-8'); $adid = $_GET['adid']; $min_limit = 10; $max_limit = 50; // css for menu if (isset($_POST['submit'])) { $monday = addslashes($_POST['monday']); $tuesday = addslashes($_POST['tuesday']); $wednesday = addslashes($_POST['wednesday']); $thursday = addslashes($_POST['thursday']); $friday = addslashes($_POST['friday']); $saturday = addslashes($_POST['saturday']); $sunday = addslashes($_POST['sunday']); // $serv1 = array_filter(array_map('trim', ($_POST['serv']))); // foreach ($serv1 as $key => $value) { // $serv .= trim($value); // if ($key != (count($serv1) - 1)) { // $serv .= " || "; // } // } $promotion = addslashes($_POST['promotion']); $urlPattern = '#^http[s]?://+#i'; $facebook = preg_replace($urlPattern, "", addslashes($_POST['facebook'])); $twitter = preg_replace($urlPattern, "", addslashes($_POST['twitter'])); $google = preg_replace($urlPattern, "", addslashes($_POST['google'])); $youtube = preg_replace($urlPattern, "", addslashes($_POST['youtube'])); $linkedin = preg_replace($urlPattern, "", addslashes($_POST['linkedin'])); if ($promotion == "") { $promotion = 0; } else { $promotion = 1; } // if promo set it as 1 if not 0 /// operning hours table $q3 = "UPDATE `opening_hours` SET `monday` = '$monday', `tuesday` = '$tuesday', `wednesday` = '$wednesday', `thursday` = '$thursday', `friday` = '$friday', `saturday` = '$saturday', `sunday` = '$sunday' WHERE `opadid` = '$adid'"; $r3 = $connect->query($q3) or die($connect->error); /// ads table $promo = "UPDATE `ads` SET `promotion` = '$promotion',`completed` = '1' WHERE `adid` = '$adid' and `memberid` = '$memberid'"; // $promo = "UPDATE `ads` SET `services_offered`= '$serv',`promotion` = '$promotion',`completed` = '1' WHERE `adid` = '$adid' and `memberid` = '$memberid'"; $promo_row = $connect->query($promo) or die($connect->error); /// promotions table $prom_title = addslashes($_POST['prom_title']); $prom_desc = addslashes($_POST['prom_desc']); $prom_date = time(); $expiry_day = addslashes($_POST['expiry_day']); $expiry_month = addslashes($_POST['expiry_month']); $expiry_year = addslashes($_POST['expiry_year']); $valid_day = addslashes($_POST['valid_day']); $valid_month = addslashes($_POST['valid_month']); $valid_year = addslashes($_POST['valid_year']); // converting valid $val = $valid_month . '/' . $valid_day . '/' . $valid_year; $prom_valid = strtotime($val); // converting expiry $expiry_dmy = $expiry_month . '/' . $expiry_day . '/' . $expiry_year; $prom_expiry = strtotime($expiry_dmy); if ($promotion == 1) { $q5 = "UPDATE promotions SET member_id = '$memberid', ad_id = '$adid', prom_title = '$prom_title', prom_desc = '$prom_desc', prom_date = '$prom_date', prom_valid = '$prom_valid', prom_expiry = '$prom_expiry' WHERE `ad_id` = '$adid' AND `ad_id` = '$adid'"; $r5 = $connect->query($q5) or die($connect->error); } if ($_POST['facebook'] != "" || $_POST['twitter'] != "" || $_POST['google'] != "" || $_POST['youtube'] != "" || $_POST['linkedin'] != "") { $q6 = "UPDATE social_links SET facebook = '$facebook', googleplus = '$google', twitter = '$twitter', youtube = '$youtube', linkedin = '$linkedin' WHERE `so_member_id` = '$memberid' AND `so_ad_id` = '$adid'"; $r6 = $connect->query($q6) or die($connect->error); } ?><script> location.href = 'editbusiness4.php?adid=<?= $adid ?>' </script><? } $am_time = [ "1.00 AM", "1.30 AM", "2.00 AM", "2.30 AM", "3.00 AM", "3.30 AM", "4.00 AM", "4.30 AM", "5.00 AM", "5.30 AM", "6.00 AM", "6.30 AM", "7.00 AM", "7.30 AM", "8.00 AM", "8.30 AM", "9.00 AM", "9.30 AM", "10.00 AM", "10.30 AM", "11.00 AM", "11.30 AM", "12.00 AM", "12.30 AM" ]; $pm_time = [ "1.00 PM", "1.30 PM", "2.00 PM", "2.30 PM", "3.00 PM", "3.30 PM", "4.00 PM", "4.30 PM", "5.00 PM", "5.30 PM", "6.00 PM", "6.30 PM", "7.00 PM", "7.30 PM", "8.00 PM", "8.30 PM", "9.00 PM", "9.30 PM", "10.00 PM", "10.30 PM", "11.00 PM", "11.30 PM", "12.00 PM", "12.30 PM" ]; // for opening times $add_que_sql = $connect->query("SELECT * FROM opening_hours WHERE opadid ='{$adid}'"); $add_row = $add_que_sql->fetch_assoc(); $monday = $add_row["monday"]; $tuesday = $add_row["tuesday"]; $wednesday = $add_row["wednesday"]; $thursday = $add_row["thursday"]; $friday = $add_row["friday"]; $saturday = $add_row["saturday"]; $sunday = $add_row["sunday"]; $monday_explode = explode(" - ", $monday); $tuesday_explode = explode(" - ", $tuesday); $wednesday_explode = explode(" - ", $wednesday); $thursday_explode = explode(" - ", $thursday); $friday_explode = explode(" - ", $friday); $saturday_explode = explode(" - ", $saturday); $sunday_explode = explode(" - ", $sunday); if (count($monday_explode) < 2) { if ($monday_explode[0] == "Closed") { $monChecked = ""; }else{ $monChecked = "checked"; } }else{ $monChecked = "checked"; $monday_from = trim($monday_explode[0]); $monday_to = trim($monday_explode[1]); } if (count($sunday_explode) < 2) { if ($sunday_explode[0] == "Closed") { $sunChecked = ""; }else{ $sunChecked = "checked"; } }else{ $sunChecked = "checked"; $sunday_from = trim($sunday_explode[0]); $sunday_to = trim($sunday_explode[1]); } if (count($tuesday_explode) < 2) { if ($tuesday_explode[0] == "Closed") { $tuesdayChecked = ""; }else{ $tuesdayChecked = "checked"; } }else{ $tuesdayChecked = "checked"; $tuesday_from = trim($tuesday_explode[0]); $tuesday_to = trim($tuesday_explode[1]); } if (count($wednesday_explode) < 2) { if ($wednesday_explode[0] == "Closed") { $wednesdayChecked = ""; }else{ $wednesdayChecked = "checked"; } }else{ $wednesdayChecked = "checked"; $wednesday_from = trim($wednesday_explode[0]); $wednesday_to = trim($wednesday_explode[1]); } if (count($thursday_explode) < 2) { if ($thursday_explode[0] == "Closed") { $thursdayChecked = ""; }else{ $thursdayChecked = "checked"; } }else{ $thursdayChecked = "checked"; $thursday_from = trim($thursday_explode[0]); $thursday_to = trim($thursday_explode[1]); } if (count($friday_explode) < 2) { if ($friday_explode[0] == "Closed") { $fridayChecked = ""; }else{ $fridayChecked = "checked"; } }else{ $fridayChecked = "checked"; $friday_from = trim($friday_explode[0]); $friday_to = trim($friday_explode[1]); } if (count($saturday_explode) < 2) { if ($saturday_explode[0] == "Closed") { $saturdayChecked = ""; }else{ $saturdayChecked = "checked"; } }else{ $saturdayChecked = "checked"; $saturday_from = trim($saturday_explode[0]); $saturday_to = trim($saturday_explode[1]); } // echo "<pre>"; // print_r($monday_explode); // print_r($tuesday_explode); // print_r($wednesday_explode); // print_r($thursday_explode); // print_r($friday_explode); // print_r($saturday_explode); // print_r($sunday_explode); // die(); // for promotion $promo_que_sql = $connect->query("SELECT * FROM ads WHERE `adid` = '$adid' and `memberid` = '$memberid'"); $promo_row = $promo_que_sql->fetch_assoc(); // $services = array_filter(explode("||", $promo_row['services_offered'])); //print_r($services); //die(); // for social $social_que_sql = $connect->query("SELECT * FROM social_links WHERE `so_ad_id` = '$adid' and `so_member_id` = '$memberid'"); $social_row = $social_que_sql->fetch_assoc(); ?> <!DOCTYPE html> <html lang="en"> <head> <title>YellowLeaf - Homepage</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href='https://unpkg.com/boxicons@2.0.9/css/boxicons.min.css' rel='stylesheet'> <link rel="stylesheet" href="/header-footer/global.css"> <link rel="stylesheet" href="index.css"> <style> .form-group input { border-radius: 4px; padding: 0 16px; } .form-group textarea { border-radius: 4px; padding: 12px 16px; } .form-group { display: block; } .form-group input[type="checkbox"] { width: 20px; height: 20px; } .form-group label { width: auto; height: auto; border: none; display: inline; } .form-group-inline { display: flex; align-items: center; } .form-group-inline input { margin-right: 8px; display: inline-block; } .mb-10 { margin-bottom: 48px; } .time-content-container { display: grid; /* grid-template-columns: repeat(2, 1fr); */ gap: 20px; margin-bottom: 2rem; } .dropdown-section { display: flex; gap: 20px; align-items: center; } .time-content-container>div { display: grid; /* grid-template-columns: repeat(3, 1fr); */ grid-template-columns: 10% 15% 1fr; gap: 20px; align-items: center; } .switch-box { display: flex; gap: 20px; align-items: center; } .time-content-container .time-switch-container { display: flex; gap: 20px; } .hide-time { visibility: hidden !important; } @media only screen and (max-width: 994px) { .time-content-container>div { grid-template-columns: 1fr; } } @media only screen and (max-width: 570px) { .time-content-container { overflow: scroll; } .form-group select { width: auto; } .switch-container .switch-box { margin: 1.3rem 0; } } </style> </head> <body> <? include 'member_menu.php'; ?> <!-- NAVBAR --> <section id="content"> <!-- NAVBAR --> <nav> <i class='bx bx-menu toggle-sidebar'></i> <a href="/members/logout.html" class="logout"> <i class='bx bx-log-out'></i> Logout </a> </nav> <!-- NAVBAR --> <!-- MAIN --> <main> <div class="container"> <h1 class="title">Submit Advert</h1> <!-- <ul class="breadcrumbs"> <li><a href="#">Home</a></li> <li class="divider">/</li> <li><a href="#" class="active">Dashboard</a></li> </ul> --> <div class="main-content"> <div class="main-box"> <? include 'advert-tab.php'; ?> <form class="submit-advert-form" id="form" action="" method="POST" enctype="multipart/form-data"> <?= $postbusiness_error ?> <!-- <div class="form-box mb-10"> <div class="form-description">Please enter products, services or facilities that your business offers.</div> <div class="form-group"> <?php for ($i = 0; $i < 4; $i++) { ?> <div class="form-box"> <input type="text" name="serv[]" placeholder="Products, services or facilities <?= $i + 1 ?>" value="<?= $services[$i]; ?>"> </div> <?php } ?> </div> </div> --> <div class="form-box mb-10"> <div class="form-description">Please enter your business opening times.</div><br> <input type="text" class="weeksInp" name="monday" value="" hidden> <input type="text" class="weeksInp" name="tuesday" value="" hidden> <input type="text" class="weeksInp" name="wednesday" value="" hidden> <input type="text" class="weeksInp" name="thursday" value="" hidden> <input type="text" class="weeksInp" name="friday" value="" hidden> <input type="text" class="weeksInp" name="saturday" value="" hidden> <input type="text" class="weeksInp" name="sunday" value="" hidden> <div class="form-group"> <div class="time-container"> <div class="time-content-container"> <div> <div>Sunday</div> <div class="switch-box"> <label class="switch"> <input type="checkbox" class="check-box" day="sunday" <?= $sunChecked ?>> <span class="slider round"></span> </label> <span>Open</span> </div> <div class="dropdown-section" id="sunday"> <div> <select id="sunday-from" class="time-dropdown"> <?php foreach ($am_time as $key => $value) { if ($sunday_from == $value) { $selected = "selected"; }else{ $selected = ""; } echo '<option value="'.$value.'" '.$selected.'>'.$value.'</option>'; } ?> </select> </div> <div>To</div> <div> <select id="sunday-to" class="time-dropdown"> <?php foreach ($pm_time as $key => $value) { if ($sunday_to == $value) { $selected = "selected"; }else{ $selected = ""; } echo '<option value="'.$value.'" '.$selected.'>'.$value.'</option>'; } ?> </select> </div> </div> </div> <div> <div>Monday</div> <div class="switch-box"> <label class="switch"> <input type="checkbox" class="check-box" day="monday" <?= $monChecked ?>> <span class="slider round"></span> </label> <span>Open</span> </div> <div class="dropdown-section" id="monday"> <div> <select id="monday-from" class="time-dropdown"> <?php foreach ($am_time as $key => $value) { if ($monday_from == $value) { $selected = "selected"; }else{ $selected = ""; } echo '<option value="'.$value.'" '.$selected.'>'.$value.'</option>'; } ?> </select> </div> <div>To</div> <div> <select id="monday-to" class="time-dropdown"> <?php foreach ($pm_time as $key => $value) { if ($monday_to == $value) { $selected = "selected"; }else{ $selected = ""; } echo '<option value="'.$value.'" '.$selected.'>'.$value.'</option>'; } ?> </select> </div> </div> </div> <div> <div>Tuesday</div> <div class="switch-box"> <label class="switch"> <input type="checkbox" class="check-box" day="tuesday" <?= $tuesdayChecked ?>> <span class="slider round"></span> </label> <span>Open</span> </div> <div class="dropdown-section" id="tuesday"> <div> <select id="tuesday-from" class="time-dropdown"> <?php foreach ($am_time as $key => $value) { if ($tuesday_from == $value) { $selected = "selected"; }else{ $selected = ""; } echo '<option value="'.$value.'" '.$selected.'>'.$value.'</option>'; } ?> </select> </div> <div>To</div> <div> <select id="tuesday-to" class="time-dropdown"> <?php foreach ($pm_time as $key => $value) { if ($tuesday_to == $value) { $selected = "selected"; }else{ $selected = ""; } echo '<option value="'.$value.'" '.$selected.'>'.$value.'</option>'; } ?> </select> </div> </div> </div> <div> <div>Wednesday</div> <div class="switch-box"> <label class="switch"> <input type="checkbox" class="check-box" day="wednesday" <?= $wednesdayChecked ?>> <span class="slider round"></span> </label> <span>Open</span> </div> <div class="dropdown-section" id="wednesday"> <div> <select id="wednesday-from" class="time-dropdown"> <?php foreach ($am_time as $key => $value) { if ($wednesday_from == $value) { $selected = "selected"; }else{ $selected = ""; } echo '<option value="'.$value.'" '.$selected.'>'.$value.'</option>'; } ?> </select> </div> <div>To</div> <div> <select id="wednesday-to" class="time-dropdown"> <?php foreach ($pm_time as $key => $value) { if ($wednesday_to == $value) { $selected = "selected"; }else{ $selected = ""; } echo '<option value="'.$value.'" '.$selected.'>'.$value.'</option>'; } ?> </select> </div> </div> </div> <div> <div>Thursday</div> <div class="switch-box"> <label class="switch"> <input type="checkbox" class="check-box" day="thursday" <?= $thursdayChecked ?>> <span class="slider round"></span> </label> <span>Open</span> </div> <div class="dropdown-section" id="thursday"> <div> <select id="thursday-from" class="time-dropdown"> <?php foreach ($am_time as $key => $value) { if ($thursday_from == $value) { $selected = "selected"; }else{ $selected = ""; } echo '<option value="'.$value.'" '.$selected.'>'.$value.'</option>'; } ?> </select> </div> <div>To</div> <div> <select id="thursday-to" class="time-dropdown"> <?php foreach ($pm_time as $key => $value) { if ($thursday_to == $value) { $selected = "selected"; }else{ $selected = ""; } echo '<option value="'.$value.'" '.$selected.'>'.$value.'</option>'; } ?> </select> </div> </div> </div> <div> <div>Friday</div> <div class="switch-box"> <label class="switch"> <input type="checkbox" class="check-box" day="friday" <?= $fridayChecked ?>> <span class="slider round"></span> </label> <span>Open</span> </div> <div class="dropdown-section" id="friday"> <div> <select id="friday-from" class="time-dropdown"> <?php foreach ($am_time as $key => $value) { if ($friday_from == $value) { $selected = "selected"; }else{ $selected = ""; } echo '<option value="'.$value.'" '.$selected.'>'.$value.'</option>'; } ?> </select> </div> <div>To</div> <div> <select id="friday-to" class="time-dropdown"> <?php foreach ($pm_time as $key => $value) { if ($friday_to == $value) { $selected = "selected"; }else{ $selected = ""; } echo '<option value="'.$value.'" '.$selected.'>'.$value.'</option>'; } ?> </select> </div> </div> </div> <div> <div>Saturday</div> <div class="switch-box"> <label class="switch"> <input type="checkbox" class="check-box" day="saturday" <?= $saturdayChecked ?>> <span class="slider round"></span> </label> <span>Open</span> </div> <div class="dropdown-section" id="saturday"> <div> <select id="saturday-from" class="time-dropdown"> <?php foreach ($am_time as $key => $value) { if ($saturday_from == $value) { $selected = "selected"; }else{ $selected = ""; } echo '<option value="'.$value.'" '.$selected.'>'.$value.'</option>'; } ?> </select> </div> <div>To</div> <div> <select id="saturday-to" class="time-dropdown"> <?php foreach ($pm_time as $key => $value) { if ($saturday_to == $value) { $selected = "selected"; }else{ $selected = ""; } echo '<option value="'.$value.'" '.$selected.'>'.$value.'</option>'; } ?> </select> </div> </div> </div> </div> </div> <!-- <div class="form-box mb-10"> <div class="form-description">Please state any promotional deals or offers that your business is currently offering. (optional)</div> <div class="form-group form-group-inline"> <input name="promotion" value="0" type="checkbox" id="promo_check"> <label for="promo_check">I wish to add a promotion</label> </div> </div> --> <!-- <div class="add-promo" style="display: none;"> <div class="form-box mb-10"> <div class="form-description">Please enter the title of your business promotion.</div> <div class="form-group"> <input value="<?= $prom_title ?>" type="text" name="prom_title" id="prom_title"> </div> </div> <div class="form-box mb-10"> <div class="form-description">Please enter the address of your business.</div> <div class="form-group"> <textarea id="prom_desc" name="prom_desc" cols="30" rows="5"><?= $prom_desc ?></textarea> </div> </div> <div class="form-box mb-10"> <div class="form-description">Please enter the date that your promotion is valid from.</div> <div class="form-group"> <div class="form-box"> <select name="valid_day"> <option value="" selected="">Day</option> <?php for ($i = 1; $i < 31; $i++) { ?> <option value="<?= $i ?>"><?= $i ?></option> <? } ?> </select> </div> <div class="form-box"> <select name="valid_month"> <option value="" selected="">Month</option> <?php for ($i = 1; $i <= 12; $i++) { ?> <option value="<?= $i ?>"><?= $i ?></option> <? } ?> </select> </div> <div class="form-box"> <select name="valid_year"> <option value="" selected="">Year</option> <?php $year = date('Y'); $lyear = $year + 50; ?> <?php for ($i = $year; $i < $lyear; $i++) { ?> <option value="<?= $i ?>"><?= $i ?></option> <? } ?> </select> </div> </div> </div> <div class="form-box mb-10"> <div class="form-description">Please enter the expiry date of your promotion.</div> <div class="form-group"> <div class="form-box"> <select name="valid_day"> <option value="" selected="">Day</option> <?php for ($i = 1; $i < 31; $i++) { ?> <option value="<?= $i ?>"><?= $i ?></option> <? } ?> </select> </div> <div class="form-box"> <select name="valid_month"> <option value="" selected="">Month</option> <?php for ($i = 1; $i <= 12; $i++) { ?> <option value="<?= $i ?>"><?= $i ?></option> <? } ?> </select> </div> <div class="form-box"> <select name="valid_year"> <option value="" selected="">Year</option> <?php $year = date('Y'); $lyear = $year + 50; ?> <?php for ($i = $year; $i < $lyear; $i++) { ?> <option value="<?= $i ?>"><?= $i ?></option> <? } ?> </select> </div> </div> </div> </div> --> <div class="form-box mb-10"> <div class="form-description">Please provide the links to your social pages. (optional)</div> <div class="form-group"> <div class="form-box"> <? if ($social_row['facebook'] == '') { $social_fb = ''; } else { $social_fb = $social_row['facebook']; } ?> <label for="">Facebook</label> <input placeholder="facebook" class="social_link_inp" type="text" name="facebook" value="<?= $social_fb ?>"> <span id="url_error_nessage"></span> </div> <div class="form-box"> <? if ($social_row['twitter'] == '') { $social_twit = ''; } else { $social_twit = $social_row['twitter']; } ?> <label for="">Twitter</label> <input placeholder="twitter" class="social_link_inp" type="text" name="twitter" value="<?= $social_twit ?>"> <span id="url_error_nessage"></span> </div> <div class="form-box"> <? if ($social_row['googleplus'] == '') { $social_ggl = ''; } else { $social_ggl = $social_row['googleplus']; } ?> <label for="">Google Plus</label> <input placeholder="google plus" class="social_link_inp" type="text" name="google" value="<?= $social_ggl ?>"> <span id="url_error_nessage"></span> </div> <div class="form-box"> <? if ($social_row['youtube'] == '') { $social_utube = ''; } else { $social_utube = $social_row['youtube']; } ?> <label for="">Youtube</label> <input placeholder="youtube" class="social_link_inp" type="text" name="youtube" value="<?= $social_utube ?>"> <span id="url_error_nessage"></span> </div> <div class="form-box"> <? if ($social_row['linkedin'] == '') { $social_lnkdin = ''; } else { $social_lnkdin = $social_row['linkedin']; } ?> <label for="">Linkedin</label> <input placeholder="linkedin" class="social_link_inp" type="text" name="linkedin" value="<?= $social_lnkdin ?>"> <span id="url_error_nessage"></span> </div> </div> </div> <button type="submit" name="submit" class="button button-yellow">Next</button> </form> </div> </div> </div> </main> <!-- MAIN --> </section> <!-- NAVBAR --> <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script> <script src="script.js"></script> <script> // var country = '<?= $countys ?>'; // var town = '<?= $town ?>'; // get_town_drop(country, town); // function get_town_drop(value, town) { // var xmlhttp = false; // var xmlhttp = (window.XMLHttpRequest) ? xmlhttp = new XMLHttpRequest() : xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); // xmlhttp.onreadystatechange = function() { // if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { // document.getElementById("town").innerHTML = xmlhttp.responseText; // return true; // } // } // xmlhttp.open("GET", "ajax/get_town.ajax.php?value=" + value + '&town=' + town, true); // xmlhttp.send(); // } $('#promo_check').change(function() { if ($(this).prop('checked') == false) { $('.add-promo').hide() $(this).val(0) } else { $('.add-promo').show() $(this).val(1) } }) const checkBox = document.querySelectorAll(".check-box"); const timeList = document.querySelectorAll(".time-list"); // console.log(timeList); const setDayOpeningHours = (day, time) => { let weeks = document.querySelectorAll(".weeksInp"); weeks.forEach(w => { let dayName = $(w).attr("name"); if (dayName == day) { w.value = time; // console.log(dayName, time); } }); } const genrateFormatedOpeningHours = (day) => { let to = $(`#${day}-to`).val(); let from = $(`#${day}-from`).val(); return `${from} - ${to}`; } checkBox.forEach((val, ind) => { let day = $(val).attr("day"); let switchBox = $(val).parent().parent(); let status = switchBox.children()[1]; $(".time-dropdown").on("change", ()=>{ if($(val).is(":checked")) { let formatedtimeval = genrateFormatedOpeningHours(day); setDayOpeningHours(day, formatedtimeval); }else{ setDayOpeningHours(day, "Closed"); } }) if($(val).is(":checked")) { let formatedtimeval = genrateFormatedOpeningHours(day); setDayOpeningHours(day, formatedtimeval); $("#"+day).removeClass("hide-time"); $(status).html("Open"); } else { setDayOpeningHours(day, "Closed"); $("#"+day).addClass("hide-time"); $(status).html("Closed"); } val.addEventListener("click", () => { if($(val).is(":checked")) { let formatedtimeval = genrateFormatedOpeningHours(day); setDayOpeningHours(day, formatedtimeval); $("#"+day).removeClass("hide-time"); $(status).html("Open"); } else { setDayOpeningHours(day, "Closed"); $("#"+day).addClass("hide-time"); $(status).html("Closed"); } }) }); const isvalidURL =(str) => { var pattern = new RegExp('^(https?:\\/\\/)?'+ // protocol '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // domain name '((\\d{1,3}\\.){3}\\d{1,3}))'+ // OR ip (v4) address '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // port and path '(\\?[;&a-z\\d%_.~+=-]*)?'+ // query string '(\\#[-a-z\\d_]*)?$','i'); // fragment locator return !!pattern.test(str); } $("#form").on("submit", ()=>{ let social_link_inp = document.querySelectorAll(".social_link_inp"); let submit = true; social_link_inp.forEach(social_url => { let url_val = social_url.value; let error_box = $(social_url).parent().children()[2]; if (url_val != '') { if (!isvalidURL(url_val)) { $(social_url).css("border", "2px solid red"); $(error_box).html("Please enter a valid url."); $(error_box).css("color", "red"); $(error_box).css("font-size", "12px"); $(error_box).css("display", "block"); $(error_box).css("border", "0px"); $(social_url).focus(); submit = false; } } }); if(!submit){ return false; } }) </script> </body> </html>