Validation rules on text fields that include spaces

  • 17 August 2021
  • 2 replies
  • 20 views

Hello,

I am creating a form that has several fields for our existing customers. I have one field that I need to add a validation rule to; it is for the customer's first name. I am looking for a way to invalidate the first name if it includes spaces as the employees who are filling these out keep putting two first names (spouses) rather than one. They know they are not supposed to do this, but they keep doing it.

 

I would like a validation error to come up that tells them they must only enter one first name. Right now I have it set to where it gives this error if the field contains " and " or " & " but I cannot find a way to do this if it contains a space. I am using SharePoint Online and Nintex Forms for Office 365.

 

Any help would be much appreciated.


2 replies

Userlevel 4
Badge +9

What kind of form are you using ? (classic, responsive, new responsive)

Userlevel 1
Badge +6

You could use input validation on the field and choose the regular expression (RegEx) method. I am not an expert in RegEx, but if you do a web search for regex to only allow letters without spaces you will probably find the correct formula to use. Using this expression seems to get you just about what you want: ^[A-Za-z][A-Za-z0-9]*$. It allows numbers, and spaces only at the end. I found it in this thread: apache flex - how to prevent white spaces in a regular expression regex validation - Stack Overflow

Reply