Bug #5632
closedJavascript SyntaxError: Nothing to repeat: in regexp for phone numbers validation
Description
This needs confirmation:
Saving a profile with a phone number gives:
Javascript SyntaxError: Nothing to repeat and fails validation without error message.
Pattern is:
"^([0-9](|-)?)?(\(?[0-9]{3}\)?|[0-9]{3})(|-)?([0-9]{3}(+|-)?[0-9]{4}|[a-zA-Z0-9]{7})$"
where
(+|-)?
has no backslash to escape the +
The string "+|-" can be found at various places unescaped.
correct string should be (and it does not allow area-codes in the form of (021) 123 123 123:
/^([0-9](\+|-)?)?(\(?[0-9]{3}\)?|[0-9]{3})(\+|-)?([0-9]{3}(\+|-)?[0-9]{4}|[a-zA-Z0-9]{7})$/
Additionally I saw on a site the + replaced by http-encoded spaces as follows:
/^([0-9]( |-)?)?(\(?[0-9]{3}\)?|[0-9]{3})( |-)?([0-9]{3}( |-)?[0-9]{4}|[a-zA-Z0-9]{7})$/
In the field edit form (but once saved with the backslash-pluses it worked.