Embed code: how to write a validation message?

Hi @GBulleri ,
You could do something like this:

window.addEventListener('message', event => {
 if (event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormReady') {
 const input = document.querySelector('input[name="property"]') // Change this to the property you want to validate
 // Error message
 const error = document.createElement('div')
 error.setAttribute('class', 'form-error-message')

 input.addEventListener('input', e => {
 if (e.currentTarget.value.length > 5) {
 // Time to display an error
 input.parentElement.appendChild(error)
 }
 })
 }
})

You would still need to use the ‘onFormSubmit’ event to prevent the form from submitting if this is unvalid.