document.write limpa a página
Por que no código abaixo sobre a chamada dedocument.write
na funçãovalidator()
os elementos de formulário (a caixa de seleção e o botão) são removidos da tela?
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function validator() {
if (document.myForm.thebox.checked)
document.write("checkBox is checked");
else
document.write("checkBox is NOT checked");
}
</script>
</head>
<body>
<form name="myForm">
<input type="checkbox" name ="thebox"/>
<input type="button" onClick="validator()" name="validation" value="Press me for validation"/>
</form>
</body>
</html>