javascript - How to send an HTML form POST request using the HTML button tag? -
as of now, have user-input structure user provides username/password clicks either "login" or register" ends post request information.
<form action="{% url 'users:login' %}" method = "post"> username: <input type="text" name="username"><br> password: <input type="password" name="passwd"><br> <input type="submit" name="login" value="log in"> <input type="submit" name="adduser" value="add user"> </form>
what want replace 2 submit buttons tags, i.e.:
<form class="control-group" action="{% url 'users:login' %}" method = "post"> <input type="text" placeholder="username" name="username"> <input type="password" placeholder="password" name="passwd"> <button class="button-style">login</button> <button class="button-style">register</button> </form>
but i'm unsure how to, example, send form's post request correct information (username, password, type (login or register)) in first example.
you can use bit javascript.
here have :
- register trigger on each button
- in triggers :
- change action url
- send form
you should register trigger on form validation, , call 1 of 2 trigger defined previously.
Comments
Post a Comment