What Makes a Travel Enquiry Form Useful for Group Bookings?
Build a Simple Travel Enquiry Form with HTML and JavaScript A travel enquiry often starts with a message such as “We need a vehicle next weekend.” Before suggesting an option, the operator still needs to know the route
Build a Simple Travel Enquiry Form with HTML and JavaScript
A travel enquiry often starts with a message such as “We need a vehicle next weekend.” Before suggesting an option, the operator still needs to know the route, date and passenger count.
A structured form can collect those details together.
This tutorial builds a small browser-only prototype using HTML and JavaScript. It generates an enquiry summary on the page. It does not send information to an operator or confirm a booking.
Choose the Essential Fields
Start with the information needed to understand the journey:
- Pickup location
- Destination
- Departure date
- Number of passengers
For group transport, luggage requirements and return dates may also be useful. Keep this first version small so the basic interaction remains easy to understand.
Build the Form
The following example includes visible labels, native browser validation and a live summary area.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Travel Enquiry Preview</title>
<style>
body {
max-width: 36rem;
margin: 2rem auto;
padding: 0 1rem;
font-family: system-ui, sans-serif;
line-height: 1.6;
color: #102a43;
}
form {
display: grid;
gap: 0.75rem;
}
input, button {
box-sizing: border-box;
width: 100%;
padding: 0.75rem;
font: inherit;
}
button {
margin-top: 0.5rem;
background: #123b70;
color: white;
border: 0;
cursor: pointer;
}
pre {
white-space: pre-wrap;
overflow-wrap: anywhere;
padding: 1rem;
background: #eef5fb;
}
</style>
</head>
<body>
<h1>Prepare Your Travel Enquiry</h1>
<p>Enter your trip details to generate a summary.</p>
<noscript>This preview requires JavaScript.</noscript>
<form id="trip-form">
<label for="pickup">Pickup location</label>
<input
id="pickup"
name="pickup"
type="text"
maxlength="150"
required
>
<label for="destination">Destination</label>
<input
id="destination"
name="destination"
type="text"
maxlength="150"
required
>
<label for="departure">Departure date</label>
<input
id="departure"
name="departure"
type="date"
required
>
<label for="passengers">Number of passengers</label>
<input
id="passengers"
name="passengers"
type="number"
min="1"
step="1"
required
>
<button type="submit">Generate enquiry summary</button>
</form>
<h2>Your Enquiry Summary</h2>
<pre id="summary" role="status" aria-live="polite">
Your trip details will appear here.
</pre>
<script>
const form = document.getElementById("trip-form");
const summary = document.getElementById("summary");
const locations = form.querySelectorAll('input[type="text"]');
locations.forEach((input) => {
input.addEventListener("input", () => {
input.setCustomValidity("");
});
});
form.addEventListener("submit", (event) => {
event.preventDefault();
locations.forEach((input) => {
input.setCustomValidity(
input.value.trim() ? "" : "Enter a location."
);
});
if (!form.reportValidity()) return;
const data = new FormData(form);
summary.textContent = [
`Pickup: ${data.get("pickup").trim()}`,
`Destination: ${data.get("destination").trim()}`,
`Departure: ${data.get("departure")}`,
`Passengers: ${data.get("passengers")}`,
"",
"Enquiry preview only. No booking has been submitted."
].join("\n");
});
</script>
</body>
</html>
Understand the Validation
The required attribute prevents empty fields from passing browser validation.
For passenger count, min="1" requires a positive value, while step="1" restricts valid values to whole numbers.
The JavaScript adds a check for location fields containing only spaces. It clears that custom error when the user edits the field.
This prototype accepts past departure dates. A production form should apply the operator’s actual date and booking rules rather than assuming every selected date is available.
Display User Input as Text
The summary uses textContent to display the entered values as plain text.
That matters because user input should not become executable page markup. A destination containing HTML-like characters should appear as text in the preview.
The aria-live="polite" region allows assistive technology to announce the updated summary without immediately interrupting the user.
Separate an Enquiry from a Booking
A passenger count alone cannot determine the correct vehicle. Luggage, seating arrangements, route requirements and availability still need discussion.
For example, Urbania Yatra offers Urbania and Tempo Traveller rentals from Ahmedabad. A structured enquiry can provide the starting details for that discussion, while vehicle availability and pricing require confirmation.
This tutorial is an independent prototype, not a description of the website’s existing implementation.
Check the Main Interactions
Before extending the example, try these cases:
- Submit with empty fields.
- Enter only spaces in a location field.
- Enter zero or a decimal passenger count.
- Complete the form with valid details.
- Enter HTML-like text and confirm it appears literally.
- Navigate the form using only the keyboard.
Extend It into a Working Enquiry System
To collect actual enquiries, connect the form to a backend endpoint and validate the submitted data again on the server. Browser validation improves the interaction, but it can be bypassed.
Display a submission confirmation only after the server accepts the enquiry. Keep that message separate from any later confirmation of vehicle availability or booking.
Once that flow works, you can add return dates, luggage notes and a preferred vehicle category.
Meta Details
| Field | Content |
|---|---|
| SEO Title | Build a Travel Enquiry Form with HTML and JavaScript |
| Meta Description | Build a browser-only travel enquiry form with HTML and JavaScript, including labelled fields, input validation and a plain-text trip summary. |
| Suggested URL Slug | build-travel-enquiry-form-html-javascript |
| Primary Keyword | travel enquiry form HTML JavaScript |
| Related Keywords | HTML form validation, JavaScript FormData, accessible web forms |
| Image Filename | travel-enquiry-form-html-javascript-urbania-yatra.png |
| Image Alt Text | Laptop showing a travel enquiry interface, with an Urbania van outside, the Urbania Yatra logo and an HTML and JavaScript tutorial heading. |
Short Description
Create a browser-only travel enquiry prototype with labelled inputs, native validation and a JavaScript summary. Learn how to separate an enquiry preview from a submitted request.
DEV.to Tags
html, javascript, webdev, beginners
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.