I have html form where user enter a date.
I need script what recognize if entered date is equal to some date from array ("takeOverArray["tz27092015", "tz21102015", "tz26092015"]") (that's working) but..
Every array value (["tz27092015", "tz21102015", "tz26092015"]) is array too (datetimes).
So full array is: takeOverArray["tz27092015["mor","lun"]", "tz21102015["lun"]", "tz26092015["eve"]"]
Now, I need when entered date from form is equal to (for example:) "tz27092015" next script will find if array "tz27092015" has specific words: "mor", "lun" or "eve". (that's not working :( and that's my problem )
My Code:
function checkTimeFunction() {
var iddate= document.getElementById("takeover_date").value; //takeover_date(input from html form)
var checkTime = "tz" + iddate.split('.').join('');
if(takeOverArray.indexOf(checkTime, 0) !== -1) //That's working {
console.log("date found");
if (checkTime.indexOf("mor", 0) !== -1) //That's NOT working {
console.log("morning disabled");
};
}
})
So my question is, why
if (checkTime.indexOf("mor", 0) == 0)
not working like previous "indexOf" above this. And how I can figure this problem.
Thanks for your help.