I want to validate phone numbers like (123) 456-7890 or 1234567890 How should be the 'matches' condition be written in the following code?
form.validate({ rules: { phoneNumber: {matches:"[0-9]+",minlength:10, maxlength:10}
Your regex should be something like
[0-9-()s]+.
[0-9-()s]+
It matches numbers, dashes, parentheses and space.
If you need something more strict, matching just your example, try this:
([0-9]{10})|(([0-9]{3})s+[0-9]{3}-[0-9]{4})
1.4m articles
1.4m replys
5 comments
57.0k users