I have a text field that I'm actually using as a field where respondents input their email. I want to put a validation that checks if the inputted text ends with our company domain. How can this be achieved?
Using JavaScript Custom Validation
Although this is possible using regular expressions, my recommendation would be to use the "Custom validation" to instead validate the input using some JavaScript. In my personal opinion is JavaScript can be easier to read and understand. Here are the steps you could use:
Drag and drop a textfield in your form
In the components settings navigate to validation tab and go to the "custom validation" section
Here enter the following JavaScript to check the input ends in the correct domain
valid = instance.getValue().endsWith('@companydomain.com')
Under the validation tab it's also a good idea to update the "Custom Error Message" property to display a message to notify the user of why the input is invalid (e.g. please enter an email address from the company domain)
Using JavaScript Custom Validation
Although this is possible using regular expressions, my recommendation would be to use the "Custom validation" to instead validate the input using some JavaScript. In my personal opinion is JavaScript can be easier to read and understand. Here are the steps you could use:
Drag and drop a textfield in your form
In the components settings navigate to validation tab and go to the "custom validation" section
Here enter the following JavaScript to check the input ends in the correct domain
valid = instance.getValue().endsWith('@companydomain.com')
Under the validation tab it's also a good idea to update the "Custom Error Message" property to display a message to notify the user of why the input is invalid (e.g. please enter an email address from the company domain)