Open In App

How to use formaction attribute in HTML ?

In this article, we will learn how to use the formaction attribute in HTML. Basically, the information attribute is used to define where to send the data of the form after submitting the form the working of formaction will begin. It overrides the feature of the action attribute of the <form> element

Why do we use formaction Attribute



Let’s suppose, we have two submit buttons in one form and both the buttons work separately and redirect to another URL of the page. Both buttons send data to different pages.

Values: It contains the physical address of the location of the file where to send the form data. 



Two possible values are –

Example: In this example, we will use the formaction attribute in HTML




<!DOCTYPE html>
<html>
   
<head>
    <title>
        How to use formAction Attribute in HTML ?
    </title>
</head>
   
<body style="text-align:center;">
    <h1>
        GeeksForGeeks
    </h1>
    <h2>
        How to use formAction Attribute in HTML?
    </h2>
    <form method="get" target="_self">
        Username:<input type="email" name="ename"><br><br>
        Password <input type="password" name="passwrd"><br>
        <input type="submit"
               value="submit for Java User"
               formaction=
 
        <input type="submit"
               value="submit for python User"
               formaction=
    </form>
</body>
 
</html>

Output:


Article Tags :