-1
I am making a code with Typescript and I check if a field has less than 9 digits, if it has less than 9, should not proceed to Ubmit, but for some reason it is proceeding.
<form method="post">
Nome: <input type="text" id="nome"/>
<button type="submit" id="enter">Submit</button>
</form>
My typescript code looks like this:
document.getElementById("enter").addEventListener("click", function () {
if ((<HTMLInputElement>document.getElementById("nome")).value.length < 9) {
(<HTMLInputElement>document.getElementById("tet")).innerHTML = "O Campo \"Nome\" deve conter 9 dígitos.";
setTimeout(function () {
(<HTMLInputElement>document.getElementById("tet")).innerHTML = "";
}, 5000);
return false;
}
});
and is inside a
window.onload = function () {}
and right after him, still inside the onload
has a
(<HTMLInputElement>document.getElementById("form")).addEventListener("submit", function () {
});
still inside the window.onload
.
What am I doing wrong?
Just for the sake of consciousness: you have an element with the id
tet
on screen, right?– Jéf Bueno
I have yes kkk @LINQ
– user149429