How to

How to submit HTML Form to WhatsApp | Sending Form fields to WhatsApp Using HTML,CSS and Javascript

Ravindra Kumar

Whatsapp Form Code Generator Tool
In this post I am going to explain how can we submit HTML form to WhatsApp. By using this functionality form’s data will be summited to chat interface of WhatsApp, As normally we chat on WhatsApp. This example will tell you about sending form fields to WhatsApp by using JavaScript.

Step 1:

First you need to design a HTML form and give the id to each input field because these id will be used in JavaScript code to send the data to WhatsApp such as

<input type="text" id="name" class="form-control" placeholder="Name" required>

and in the form element you just need to use action attribute and you also need to use a button by pressing this button the input fields will be sent to WhatsApp by using JavaScript code so you can use button as following

Responsive Landing page source code in Html, CSS and Bootstrape

<button type="button" class="btn btn-primary" onclick="whatsapp();">
Submit
</button>

HTML Code

<form action="#" class="form-group">
<div class="mb-3">
<input type="text" id="name" name="name" class="form-control" placeholder="Name" required>
</div>

<div class="mb-3">
<input type="email" id="email" name="email" class="form-control" placeholder="Email" required>
</div>

<div class="mb-3">
<input type="text" id="phone" name="phone" class="form-control" placeholder="Phone Number" required>
</div>

<div class="mb-3">
<textarea id="message" name="message" rows="5" class="form-control" placeholder="Message"></textarea>
</div>

<div class="text-end">
<button type="button" class="btn btn-primary" onclick="whatsapp()">
Submit
</button>
<button type="button" class="btn btn-danger" data-bs-dismiss="modal">
Cancel
</button>
</div>
</form>

Step 2:

Now, Create a JavaScript function called whatsapp() and this function will be called when someone clicks the button of the form and by using this function data will be sent to the WhatsApp interface.so first you need to take some variables which is used to hold the values of input fields.

JavaScript Code

<script>
function whatsapp() {
var name = document.getElementById("name").value;
var email = document.getElementById("email").value;
var phone = document.getElementById("phone").value;
var message = document.getElementById("message").value;

// Basic validation
if (!name || !email || !phone) {
alert("Please fill all required fields");
return;
}

var whatsappNumber = "9182728581";

var text =
"*Name:* " + name + "\n" +
"*Email:* " + email + "\n" +
"*Phone:* " + phone + "\n" +
"*Message:* " + message;

var url = "https://wa.me/" + whatsappNumber + "?text=" + encodeURIComponent(text);

window.open(url, "_blank");
}
</script>

I hope you got all information which was required to make this form and send it to WhatsApp. You can check the following videos as well.

Submit HTML form’s data to Google Sheet | Sending HTML Form’s data to google sheet

[Download]Responsive Login Page Using HTML, CSS, and JavaScript

Sign Up page design Source Code Using HTML, CSS and Bootstrap

Responsive Landing page source code in Html, CSS and Bootstrape

Whatsapp Form Code Generator Tool

Ravindra Kumar

Ravindra is a passionate full stack developer and dedicated blogger with a flair for crafting user-friendly web applications and insightful articles. With expertise spanning front-end and back-end technologies, Ravindra brings ideas to life through innovative coding solutions.

Suggested Reading

LMS / Course Management System Frontend Source Code in HTML,CSS & Javascript

Front-end source code is the visible element of an LMS or CMS. It governs how students, professors, and supervisors use the system. Thanks to Online course website source code in HTML, CSS, and JavaScript, the site’s front end is easy to use, appealing, and interactive. It is how users access classes, keep track of their […]

LMS / Learning Management System Project with Source Code in PHP Laravel

Laravel learning management system project with source code Learning Management System (LMS) or Course Management System (CMS) projects simplify online educational content creation, management, and sharing. The initiative centralizes course materials, progress tracking, and learning activities for teachers and students. An LMS or CMS’s front-end and back-end must be created to ensure user satisfaction. The […]

Ecommerce Website Frontend source Code in HTML,CSS,Javascript & Bootstrap

Front-end source code makes up an eCommerce website’s UI. This code is crucial to buyer-site interaction.  It includes the structural, visual, and engaging parts that make the user’s experience unique. Online shopping Website frontend source code was created with HTML, CSS, JavaScript, and different frameworks, ensuring the website works and looks good. HTML: Structuring the Web Pages […]

Download Free Footwear Ecommerce Store Website Template using HTML, CSS, JS

Create a Stylish Online Shoe Store in Minutes This free footwear store homepage template is designed for modern shoe brands, fashion boutiques, and online retailers.With a sleek, responsive layout and clean code, you can quickly build a website that looks professional and performs beautifully on all devices. Key Features Fully responsive and mobile-friendly Clean and […]

How to Create a WhatsApp Form on WordPress Using Ravindra Chat Form Plugin

WhatsApp has become the fastest way for customers to contact businesses online. Instead of waiting for emails or filling long contact forms, users prefer instant messaging. That’s why adding a WhatsApp form on your WordPress website is a smart move for lead generation and customer engagement. In this guide, you’ll learn how to create a […]

Whatsapp Contact Form Source Code Html CSS Javascript

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Contact Form</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"> <style> body { background-color: #f8f9fa; } .contact-form { max-width: 600px; margin: 50px auto; padding: 20px; background: #fff; border-radius: 10px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); } </style> </head> <body> <div class="container"> <div class="contact-form"> <h2 class="text-center mb-4">Contact Us</h2> […]

Making WhatsApp Order Form using HTML, CSS, Javascript

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Order Form</title> <!-- Bootstrap CSS --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous"> <script> function sendOrderToWhatsApp() { // Retrieve form values var name = document.getElementById('name').value; var email = document.getElementById('email').value; var contact = document.getElementById('contact').value; var address = document.getElementById('address').value; var pincode = document.getElementById('pincode').value; var landmark = document.getElementById('landmark').value; // Retrieve product selections var […]

B2B / Wholesale E-Commerce Website Template

External resource

Professional Invoice HTML Templates

External resource