I need to verify if user have entered desired characters in the input field and if he didn’t, I need to format input like this:
Start variable: +42 88 66 44 3, +42 (4) 87/654321; +42 3 123456
Desired variable: +428866443, +42487654321, +423123456
So basically I need to clear out all characters from variable that are not numbers and allow only signs like + , ; -.
Because I’m using an AJAX request, I would appreciate code for both PHP and Javascript.
For striping invalid chars from your string use regular expression in PHP and JAVASCRIPT.
PHP
JAVASCRIPT
But better practice is that you show error, if user enters wrong format. You will need some validating to todo…