I know, that's why its wrong, but you trying the door is a separate issue from the fact someone else might have wandered past. You just could have inflamed the situation, that's all. Not the crime of the century, by any means.
I agree that a word to the parents would probably make them think twice about doing it again. They probably thought, my child, my choice, the child is asleep and they didn't want to disturb him, and weighed up the risk against the benefit.
I just did a quick google. There doesn't seem to be a specific law here in the UK. Here is an excerpt from Times Online.
Scenario 1: You have three children under 5. You go shopping at the supermarket for 20 minutes, leaving them asleep in their car seats with the doors unlocked to avoid their movements triggering the car alarm.
This scenario is not advisable. It is an offence under section 1 of the Children and Young Persons Act 1933 to neglect or abandon a child under the age of 16 for whom a parent or carer has responsibility, but the law gives no detail of what amounts to neglect or abandonment. Prosecution and/or conviction depend largely on the circumstances. The punishment can range from a fine to ten years? imprisonment.
The court is to likely to take into account the age and maturity of the child, for how long he or she was left alone and the arrangements to ensure his or her safety. Here, the children might get out of the car and wander on to the road ? or anybody could remove a child from the car.
If the car doors were locked the children might be safer, but then what might happen if the children became very distressed in an enclosed space? Technically, children should not be left alone like that until they are 16. Five minutes might be acceptable in a locked car; 20 minutes is too long"