Every line of 'time validation in javascript' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
69 function validateTime(value) { 70 var check = false; 71 var adata = value.split(':'); 72 var hours = parseInt(adata[0], 10); 73 var minutes = parseInt(adata[1], 10); 74 if ((hours > 24) && (minutes > 60)) { 75 check = false; 76 } else { 77 check = true; 78 } 79 return check; 80 }
Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code
139 function validateTime(strValue){ 140 return (strValue == timeToString(stringToTime(strValue))) 141 }
36 'time' : function validate_time(s_time) { 37 // check format 38 if (!re_tm.test(s_time)) 39 return false; 40 // check allowed ranges 41 if (RegExp.$1 > 23 || RegExp.$2 > 59 || RegExp.$3 > 59) 42 return false; 43 return true; 44 }
75 export function isTimeValid(value, disabledTime) { 76 const disabledTimeConfig = getTimeConfig(value, disabledTime); 77 return isTimeValidByConfig(value, disabledTimeConfig); 78 }
115 function validTime (dt) { 116 if (dt && typeof dt === 'string') { 117 var r = reTime.exec(dt) 118 if (r) { 119 var h = parseInt(r[1]) 120 var m = parseInt(r[2]) 121 return h >= 0 && h <= 23 && m >= 0 && m <= 59 122 } 123 } 124 return false 125 }
55 export function isTimeValid(value: CandyDate, disabledTime: DisabledTimeFn): boolean { 56 const disabledTimeConfig = getTimeConfig(value, disabledTime); 57 return isTimeValidByConfig(value, disabledTimeConfig); 58 }
169 export function isTimeInput(value: unknown) { 170 return ( 171 isTimeInputHrTime(value) || 172 typeof value === 'number' || 173 value instanceof Date 174 ); 175 }
386 isValidTime(dateToCheck, firstPossibleTime, lastPossibleTime) { 387 return dateToCheck.isBetween(firstPossibleTime, lastPossibleTime, undefined, '[]'); 388 }
17 export function validateTime(str) { 18 const validLength = str 19 .split(/(:|am|pm)/gi) 20 .filter(val => val.trim().length) 21 .reduce((prev, cur, i) => { 22 return prev && i < 4 && cur.length < 3 && isValidVal(i, cur); 23 }, true); 24 const validTime = str.match(/(\d{1,2}):(\d{2})/g); 25 const containsMeridian = str.indexOf("am") > -1 || str.indexOf("pm") > -1; 26 return validLength && validTime && containsMeridian; 27 }
87 function isDateValid(value) { 88 const matched = value.match(dateRe); 89 90 if (matched) { 91 const epoch = Date.parse(value); 92 if (!epoch && epoch !== 0) return false; 93 94 const d = new Date(epoch); 95 d.setTime(d.getTime() + d.getTimezoneOffset() * 60 * 1000); 96 97 if ( 98 d.getFullYear() == matched[1] && 99 d.getMonth() + 1 == +matched[2] && 100 d.getDate() == +matched[3] 101 ) { 102 return true; 103 } 104 } 105 106 return false; 107 }