Need code that'll prevent posts with "bad words"
-
So I use the “PreimumPress” Classifieds Blue child theme, and the code I have below will check if there is a “bad word” entered into the Keywords input/field and alerts the user about it once they click on the Save Listing button. The problem though is that it ONLY alerts the user when there is just ONE of the specified “bad words” in that field. It won’t trigger the alert when the “bad word” is found within a whole sentence. So I need help with two things…
– Can anyone help me tweak this code so that it will trigger the alert when the “bad word” is found ANYWHERE within that field, even if there are other words.
– Can anyone help me have this “alert” happen when the specified “bad words” are in ANY field, not just the “keywords” field.*For reference, my website is https://www.lakomai.com
THANKS!!
<script> jQuery(function() { jQuery("#MainSaveBtn").on("click",function() { var name = jQuery("input:text[name='custom[post_tags]']").val(); var badwords = ["word1", "word2", "bad word3"]; if(jQuery.inArray(name, badwords) !==-1) { alert("Your Listing Contains Bad Words, Please Remove Them Before Proceeding"); return false; } }); }); </script>
- The topic ‘Need code that'll prevent posts with "bad words"’ is closed to new replies.