I’m trying to make a function to check, anytime something is changed on my page, if all input is valid. I thought the best way to do this, rather than attach the function to every input would be to put it on the entire page (hence html/body tag,) but this didn’t seem to work in that nothing happened. My code looks like:
<body onchange="removewarn()">
.
form elements
.
.
</body>
and the function
function removewarn(){
if(all input is valid)
{
document.getElementById('warning').style.visibility="hidden";
}
}
The point of which, is to remove a warning put on the page if all elements are not filled in or are not valid.
The
onchangeevent is only supported by inputs, selects and textareas, wich is why your function will never be called if you try to bind it to the body tag.You will either have to bind it on every input, or to use something like jQuery’s delegate method.