Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

overlapping times javascripts html django

var timeList = [];

function addTime() {
  var startTime = document.getElementById("startTime").value;
  var endTime = document.getElementById("endTime").value;

  if (validate(startTime, endTime)){
    timeList.push({
      startTime: startTime,
      endTime: endTime
    });
    print(timeList);
    document.getElementById("error").innerHTML = "";
    }
  else
    document.getElementById("error").innerHTML = "Please select valid time";
}

function validate(sTime, eTime) {
  if (+getDate(sTime) < +getDate(eTime)) {
    var len = timeList.length;
    return len>0?(+getDate(timeList[len - 1].endTime) < +getDate(sTime) ):true;
  } else {
    return false;
  }
}

function getDate(time) {
  var today = new Date();
  var _t = time.split(":");
  today.setHours(_t[0], _t[1], 0, 0);
  return today;
}
function print(data){
  document.getElementById("content").innerHTML = "<pre>" + JSON.stringify(data, 0, 4) + "</pre>";
}
Comment

overlapping times javascripts html django

<input type="text" id="startTime" />
<input type="text" id="endTime" />
<button onclick="addTime()">Add Time</button>
<p id="error"></p>

<div id="content"></div>
Comment

PREVIOUS NEXT
Code Example
Javascript :: pass object in onclick javascript 
Javascript :: svelte reactive async 
Javascript :: java code that writes code in powerpoint 
Javascript :: js im mobile hover id 
Javascript :: es6 strip child is null from object 
Javascript :: prefix increment 
Javascript :: python config file json datatypes 
Javascript :: find cypress running in ci or open mode 
Javascript :: rangeSlider format price js 
Javascript :: dojo create app 
Javascript :: how to update value in nested json using id in javascript 
Javascript :: reduce javascript acc became numeber insted array 
Javascript :: solr regex expression 
Javascript :: dom javascript cheat sheet 
Javascript :: chrome back button click event react 
Javascript :: element ui loading schange text 
Javascript :: implement subscript operator js 
Javascript :: whait till src img has loaded angular 
Javascript :: how-to-avoid-to-exceed-rate-limit-by-using-discord-js-api 
Javascript :: Escaping special characters in JSON / list of invalid characters to strip from JSON string 
Javascript :: js event problem solving 
Javascript :: jquery to vanilla js converter 
Javascript :: complete date 
Javascript :: z-song laravel-admin unable load js fucntion untill use f5 
Javascript :: json volley dependency 
Javascript :: Getting data from one axios to another in componentDidMount 
Javascript :: Setting Up Multiple Event Responses 
Javascript :: class exists javascript 
Javascript :: vuex get data in mounted 
Javascript :: mapbox gl js openpopup on a marker 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =