I can not find solution to detect that an input type time is almost (hour) or completely (hour + minute) filled .
This solution could allow me to prevent that a period is completely write: ex : morning and afternoon : from 08h00 to 19h00 (24h)
I create a condition to form submission which display a message error if morning or afternoon isn't filled.
(If After submission I have that : from {08h00} to {..h..} ) :
If afternoon is finally filled , return true .
If afternoon doesn't exist condition is applied to morning to verify if it's erased - then the message error is removed . But it seems that Jquery defined an input type time empty as soon as "minute" part is erased using on.('keyup') function to determined each moment of user erased .
Many user doesn't know clicking outside the input field after deletion allow me to detect erased input, so I can't use .blur() function.
For this configuration:
from {08h..} to {..h..} . first input has class "classofinput".
jQuery('classofinput').val() === ""; or jQuery('classofinput').length == 0;
Jquery return true
or jQuery('classofinput').val() !== ""; or jQuery('classofinput').length > 0;
Jquery return false
Edit - Code example : Codepen Input[type="time"]
//Html
<input type="time">
//Jquery
//If somebody has a solution ?
$(document).on("change", "input", function () {
console.log($(this).val());
});
//doesn't work
//Keyup, keydown, blur, focusIn or FocusOut , change, text(), html().
/* 1
$('input').blur(function () {
console.log($(this).val());
});
*/
/* 2
setTimeout(function(){
console.log($(this).val());
});
*/
/* 3
console.log($(this).delay(20).val());
*/