Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function totalHours(){
  2.   var start = document.getElementById("starttime").value;
  3.   var end = document.getElementById("finishtime").value;
  4.   var breaks = document.getElementById("breaktime").value;
  5.  
  6.  
  7.   var hours = parseTime(end) - parseTime(start);
  8.  
  9.   var out = (hours / 60) - breaks;  
  10.  
  11.   $('#totalhours').val(out);
  12.   $('#totalhours').trigger('input');
  13.  
  14.   // document.getElementById("totalhours").value= out;
  15.  
  16.   // document.getElementById("breaktime").value=0;
  17.  
  18.  
  19.  
  20. function parseTime(s) {
  21.   var c = s.split(':');
  22.   return parseInt(c[0]) * 60 + parseInt(c[1]);
  23. }
  24. }
  25.  
  26. $(document).ready(function() {
  27.   $("#breaktime").keyup(function(){
  28.     totalHours();
  29.   });
  30. });
  31.  
  32. // function nantest(){
  33. //   var value = document.getElementById("totalhours").value;
  34. //   alert(isNan(value));
  35. // }
  36.  
  37. $(document).ready(function() {
  38.   $('#totalhours').validator({
  39.     custom : {
  40.       hourcheck : function($el) { return Boolean($el.val() >= 1);}
  41.       },
  42.     errors: {
  43.       hourcheck : "Your number of hours must be positive."
  44.       }
  45.   });
  46. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement