I\'ve got the following HTML5 form: http://jsfiddle.net/nfgfP/
Okay, oninvalid works well but it shows error even if user entered valid data. So I have used below to tackle it, hope it will work for you as well,
oninvalid="this.setCustomValidity('Your custom message.')" onkeyup="setCustomValidity('')"
oninvalid="this.setCustomValidity('Your custom message.')"
onkeyup="setCustomValidity('')"