Table of contents
In this example, I will show you submit HTML form without pressing the button or displaying the submit button. Sometimes we need a process to submit the form without a button. Here I will show you an example of how to do it.
Â
Original Form with Button
In this example, you can see that the code below will display the submit button but still you can submit the form without/with the button.
Â
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
</head>
<body>
<form action="post.php" method="post">
<input name="username" type="text" /><br />
<input name="password" type="password" />
<input type="submit" />
</form>
</body>
</html>
Â
Solution: Hiding the form Button
Now let's hide the button to just submit the form without it.
Â
See the example code below:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<style type="text/css">
.hidden-submit-btn {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
</style>
</head>
<body>
<form action="post.php" method="post">
<input name="username" type="text" /><br />
<input name="password" type="password" />
<input type="submit" class="hidden-submit-btn" />
</form>
</body>
</html>
Â
As you can see I just added the class named hidden-submit-btn
to call the style above I added it so that it will hide the submit button but still have the same function as the original code.
Â
I hope it helps. Thank you for visiting.