whymatt
whymatt

Reputation: 27

Regular Expression Not Validating Correctly

I'm using the following: (/^[A-Za-z0-9 '-\/]{3,20}$/) to validate an address.

Something like "27a/67 Mount View Rd" is permitted, but when entered as "Unit 27a/67 Mount View Rd" OR "27a / 67 Mount View Rd" it returns false.

The regular expression allows for spaces, so why is it refusing to validate the latter addresses?

You can test it out here: http://www.melbournemeditationcentre.com/meditation-courses/course-registration/

Upvotes: 1

Views: 39

Answers (1)

Floris
Floris

Reputation: 46395

27a/67 Mount View Rd
27a / 67 Mount View Rd
Unit 27a/67 Mount View Rd
    ^    ^    ^    ^
    5   10   15   20

You have more than 20 characters in your invalid strings...

Upvotes: 4

Related Questions