I have a input field for a phonenumber.
Now i want to check with jquery/javascript the syntax and the characters of the number
I only accept this format: 31-123456789 (also more groupes seperated by - will be ok)
Its important to check if there is the international code at first.
I think about to do a kind of replace for replace "()/.:;" characters and check if the first letter is a 0.
But this looks for large code, also there is not check if the user has enter disallowed characters for example Abc...
How i can check and format the following examples in the easiest way?
031(123)123 -> should return 31-123-123
(0123)123 -> should return a error (no international code)
031.123 -> should return a error (no international code)
31.(123)123 -> 31-123-123
+31.123.123 -> 31-123-123
+31 (123) 123 -> 31-123-123
etc.
Thanks for showing and explaing me the way to do it.