Disable or Block links entered in...

User 182385 Photo


Registered User
2 posts

Does anyone have a good way to disable or block links (URLs) from being entered in the comment fields of Web Form Builder contact forms?
Ingrid
User 187934 Photo


Senior Advisor
20,181 posts

Hi Ingrid,
Here's one way. I'm using the code to hide and disable the submit button if there's a link detected within a textarea named comments.
Paste this into a html element in your form. change the name of the textarea to match yours or change the textarea to input if your using a plain text input.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
var jQ = $.noConflict(true);
jQ(document).ready(function(){
jQ("textarea[name='comments']").change(function(){
var comments = jQ("textarea[name='comments']").val();

var urls = comments.match(/\b(http|https)?(:\/\/)?(\S*)\.(\w{2,4})(.*)/g);
console.log(urls);
if (jQ(urls).length > 0){
jQ(':input[type="submit"]').hide();
jQ(':input[type="submit"]').prop('disabled', true);
console.log("It has a link");
}else{jQ(':input[type="submit"]').prop('disabled', false);
jQ(':input[type="submit"]').show();
console.log("It doesn't have a link");
}
});
});
</script>

I wasn't totally sure on how you actually wanted handle the links within the comments.
Working here.
https://ericrohloff.com/coffeecup/ccfor … -comments/
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 182385 Photo


Registered User
2 posts

Thank you, just saw this, tested it and it works.

I might want a modification like to change the HIDE to showing an Error text where the Submit button was.
Ingrid
User 482719 Photo


Registered User
8 posts

Spammers are everywhere, especially from overseas.
I want to block ALL URL's in the comments section of my forms as well.

I have added the code submitted by Eric above into the html elements, but they are still sending links.
I am also using captcha. It works from my machine and phone. How are they still posting links?

Maybe I've missed a setting. Could you please explain the settings beyond pasting and renaming "comments"??
Thanks!

User 187934 Photo


Senior Advisor
20,181 posts

Hi Wannab,
They maybe disabling js.
You could try this.
Paste this code into a html element below your comment box. Adjust the mydomain to yours or where ever you want to send them if js is disabled.
<noscript><h2> You must have JavaScript enabled in order to use this order form. Please
enable JavaScript and then reload this page in order to continue.</h2>
<meta HTTP-EQUIV="refresh" content=3;url="https://mydomain.com"></noscript>
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 482719 Photo


Registered User
8 posts

Thanks for your quick response!!
I've put the code in my forms and now we just wait and see!

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.