Hidden even Function ID generates error

0

As it was not clear I will redo the doubt.

follow the code that works as desired.

<html>
<head>
    <title>Teste</title>
</head>
<body>
    <form action="/teste_andre.html" method="get" id="form1" onsubmit="return valida()">
        <input type='hidden' value='1' name='teste' id='teste'>
    </form>

    <button type="submit" form="form1" value="Submit">Submit</button>
    <script type="text/javascript">
        function valida(){alert('valida');}
    </script>
</body>
</html>

If I change the ID of the field type hidden from 'test' to 'validate' It does NOT show the alert and it does not give an error in the console.

I just want to know why hidden can not have the same id of the function name?

    
asked by anonymous 09.08.2017 / 20:38

1 answer

-2

Good afternoon, friend, this is a javascript error, it ends up getting confused and prevents you from using both with the same names.

If you'd like to see more details, you can check out this answer: link

    
09.08.2017 / 21:34