purplewurple
Novice

Validation rules on text fields that include spaces

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.

Labels: (1)
0 Kudos
Reply
2 Replies
allan
Contributor

Re: Validation rules on text fields that include spaces

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

0 Kudos
Reply
David-
Scout

Re: Validation rules on text fields that include spaces

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

0 Kudos
Reply