Field Validator - Does Not Include x

Hi, I am wanting to create a form field that has a validation. I’ve came across examples where a field ‘must include’ a certain text string eg. https://

Reference: How to make sure certain text is included in a form input?

I want to do the opposite. So basically I need to stop the form being submitted if it includes www. or a certain text string for example. Can anyone help with this?


Here is my site Read-Only: LINK
(how to share your site Read-Only link)

Here’s a possible solution. Create regex that looks for www. then alerts the user if they enter that specific string

var regex = /www./i;
var userInput = document.getElementById(‘inputField’).value; // Get the user input from the form field with id ‘inputField’

if (regex.test(userInput)) {
alert(‘Please remove “www.” from your input.’); // Display an alert if “www.” is found in the user input