I know that you can validate with HTML5 or CSS, but it's just out of curiosity: I found a code on the net that verifies that the syntax of a typed email is correct:
if(document.dados.email.value=="" || document.dados.email.value.indexOf('@') == -1 || document.dados.email.value.indexOf('.') == -1 )
{
And it works. The problem is that I can not understand how this "-1" conditional value can be legitimate if there is no negative array or string value.
However based on a lint of logic I assumed that "-1" meant "does not exist", hence I modified this to <0
and then to <1
and both worked as well.
Could you please give me a clearer explanation of this case?