Link to home
Start Free TrialLog in
Avatar of Quack
QuackFlag for United States of America

asked on

my regular expressions isnt' working...need one for a POC form field that can include alphabetic characters [commas] [periods] and [spaces]

my regular expressions isnt' working...need one  for a POC form field that can include alphabetic characters [commas] [periods] and [spaces]

current regex is:
		, Contact_POC: {
				required: true
			  , pattern: /^[a-zA-Z0-9,-.!? ]*$/
			}

Open in new window


throwing an invalid message though when John Doe Test2 is used...anyone have any ideas?
Avatar of Terry Woods
Terry Woods
Flag of New Zealand image

This part may be making it fail:
,-.

Open in new window


It says match any character between comma and period. Did you want to match a hyphen? If so, put the hyphen at the start or end of the list of characters to match. eg

/^[-a-zA-Z0-9,.!? ]*$/

Open in new window

Note you're also allowing question marks and exclamation marks with the provided pattern, as well as hyphens, and the other character you did say you wanted.
Avatar of Quack

ASKER

The Point of Contact Name can include alphabetic characters, commas, periods, and spaces
Avatar of Quack

ASKER

I didn't need the question mark but its still not taking for some reason w/ the hyphen moved...I think its failing on the space...how do I add a space?
ASKER CERTIFIED SOLUTION
Avatar of Frank Helk
Frank Helk
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Quack

ASKER

that took...thanks!
Looks like sth went wrong with choosing the correct comment for the points ?
Avatar of Quack

ASKER

worked great...sorry for the confusion