I have made a website with JS and php and as you can see below is my code at paste bin, I have looked around and seen regular expressions but I don’t know how to use them or what I should use exactly….But basically I want to just allow the user to enter north american phone numbers and if they enter anything else then give them a message to enter a valid phone number…
Below is my code to help you understand what I have..What I need and what my site’s interface looks like…
possible phone numbers user can enter are 9058554678 OR 4167641689…
This is how the the list looks:
http://dev.icalapp.rogersdigitalmedia.com.rogers-test.com/Edit.php
It’s worth reading up on regular expressions before using them, since they can be a little tricky and unintuitive.
Good tutorial: http://www.regular-expressions.info/quickstart.html
Based on what you list as a valid input, you’re looking to see if the user entered in 10 digits. This can be done by checking if a character is a digit, and then seeing if there are 10 of them, which would be the regular expression: [0-9]{10}. Example on how to use:
Test: http://jsfiddle.net/87ea8/