Prevent users from injecting hyperlinks in Form Fields
SOLVE
We are currently facing an issue with users trying to inject hyperlinks in form fields like first and last name, and currently, there is no solution from Hubspot.
The AI support Chatbot asked me to use the following code to prevent this from happening:
<script>document.addEventListener("DOMContentLoaded", function () { const form = document.querySelector('#formid'); if (!form) { console.log("Form not found."); return; } form.addEventListener('submit', function (e) { const inputs = form.querySelectorAll('input, textarea'); let valid = true; inputs.forEach(input => { console.log(`Checking input: ${input.value}`); const pattern = /https?:\/\/[^\s]+/; if (pattern.test(input.value)) { valid = false; alert('No hyperlinks allowed!'); console.log('Hyperlink detected:', input.value); } }); if (!valid) { console.log('Form submission blocked due to hyperlink.'); e.preventDefault(); } });});</script>
But sadly, it didn't work. Looking for any help to solve this issue.
Prevent users from injecting hyperlinks in Form Fields
SOLVE
Do you have access to edit the property fields? You can put a rule on the property to disallow certain characters which would also be applied to forms, I believe.
Prevent users from injecting hyperlinks in Form Fields
SOLVE
Do you have access to edit the property fields? You can put a rule on the property to disallow certain characters which would also be applied to forms, I believe.