-1

I have a HTML form, and a button inside of it, witch isn't submit. And when i click it, it sends the form, and reloads the page. Witch i don't want. I'd like to dissociate that button from the form it's in. Google didn't helped much. Here is the form :

      <form action="" method="post">

        <div class="form-group">
            <label for="jdrName">Nom du jeu de rôle :</label>
            <input type="text" class="form-control" name="jdrName"
                  placeholder="Nom du jeu">
        </div>

        <div class="form-group">
          <label for="jdrGenre1">Genre associé au jeu</label>
          <input type="text" class="form-control" name="jdrGenre1">
          <button id="addGenre" class="btn btn-success">Ajouter un genre</button>
        </div>

        <div class="form-group">
            <label for="jdrName">Date de sortie :</label>
            <input type="date" class="form-control" name="gameRelease">
        </div>

        <div class="form-group">
          <label for="jdrDescription">Description du jeu</label>
          <textarea class="form-control" name="jdrDescription" rows="5"
          placeholder="Entrez ici une description succinte du jeu"></textarea>
        </div>

        <div class="form-group">
          <label for="jdrLink">Lien vers le site du jeu</label>
          <input type="text" class="form-control" name="jdrLink">
        </div>

        <button type="submit" class="btn btn-primary">Valider</button>
      </form>

Thanks !

1 Answers1

1

You must precise that the button is of type="button", the default type being submit.

Grégory Huyghe
  • 422
  • 1
  • 6
  • 18