diff --git a/app/javascript/maps/visits.js b/app/javascript/maps/visits.js
index b55b52d2..3a60c0e0 100644
--- a/app/javascript/maps/visits.js
+++ b/app/javascript/maps/visits.js
@@ -1358,11 +1358,15 @@ export class VisitsManager {
Location
@@ -1431,6 +1435,12 @@ export class VisitsManager {
const newName = event.target.querySelector('input').value;
const selectedPlaceId = event.target.querySelector('select[name="place"]').value;
+ // Validate that we have a valid place_id
+ if (!selectedPlaceId || selectedPlaceId === '') {
+ showFlashMessage('error', 'Please select a valid location');
+ return;
+ }
+
// Get the selected place name from the dropdown
const selectedOption = event.target.querySelector(`select[name="place"] option[value="${selectedPlaceId}"]`);
const selectedPlaceName = selectedOption ? selectedOption.textContent.trim() : '';