Is it illegal to lock a toddler in his room before he wakes up to prevent him from getting into harmful chemicals while the parents are occupied.
Maybe and maybe not depending on many details that you did not share.