Regex to validate email ids in InfoPath

Requirement – InfoPath form’s column should allow multiple valid email ids to be keyed in, separated by a comma.

InfoPath allows validation of an email id by default. It has a pattern to compare to. However, when the need arises to have multiple email ids inserted in a column, how to validate if all are valid email ids and are separated by a comma?

Solution – Write a validation rule for the column. The condition would be

Field: Email

Condition: does not match pattern

Custom pattern:  ([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\s*,\s*([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3}))*

Email

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s