Hey all!
Have spent the last few days struggling with getting data from a client website to pass through the Integromat correctly (as it wouldn’t recognize “google.com” or a URL without a http/https prefix as a valid URL). However, with the help of a couple forums online, I was able to write a JavaScript function that validates that a URL contains “http”, or else it will add it in.
function checkURL() {
var myURL = document.getElementById('Resource-Link').value
var validatedURL = myURL.includes('http')
if (myURL == "") {
return "No value to test."
} else if (validatedURL) {
return myURL
} else {
var modifiedURL = 'http://' + myURL
document.getElementById('Resource-Link').value = modifiedURL
return modifiedURL
}
}
The only thing that would need replaced within the script to work with your website would be the field name that is being referenced. In the case of my site, this is “Resource-Link”!
Hope this is able to help someone, somewhere in the Webflow-verse. Please let me know if I can assist anyone with this!