Form validation Javascript works on IE but not on Firefox

Asked

Viewed 207 times

2

Good afternoon to you all. I am trying to validate a form by checking if the value field is filled and is greater than 0.

It worked perfectly in IE, but in Firefox it works for nothing in the world!

Follows the code:

    <script language="JavaScript">
        function valida(){
        f = document.form2;
        var valor = f.vlrass.value;

        if (valor==""){
           alert("Informar valor original da contribuição.")
           f.vlrass.focus()
           return false;
        }
           if (valor==0){
              alert("Informar valor original da contribuição.")
              f.vlrass.focus()
              return false;
           }
    }
    </script>

And the form call:

    <input type="submit" name="Submit" value="Listar Vencimentos"" onclick="return valida()">

Any idea?

  • first mistake: <input type="submit" name="Submit" value="Listar Vencimentos" onclick="return valida()"> for <input type="submit" name="Submit" value="Listar Vencimentos"" onclick="return valida()">

1 answer

0

I can’t believe I didn’t see the extra quotes!!!! It was all because of this here:

<input type="submit" name="Submit" value="Listar Vencimentos"" onclick="return valida()">
                                              Aspa sobrando! ^
  • you have just posted a reply, to comment or make a remark click on "comment" (just below the question)

  • 1

    @Cesarmiguel He published this as an answer precisely because he found the problem.

  • @Andrey, I had not realized that I had found a solution to the problem. It seemed to me another comment before the editing.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.