Copy link to clipboard
Copied
Hi there,
can anybody tell me how or where to find a php telephone formating script, preferably from Dreamweaver exchange? I couldn't find any.
Thanks!
Copy link to clipboard
Copied
$phone = $_POST['phone'];
$phone = preg_replace('/[^0-9]/', '', $phone); # remove non-numbers
if (preg_match('/^1?[0-9]{10}$/', $phone)) {
echo 'Valid'; #or do whatever else you want it to do
}
I thought spry had a form validation criteria for a text field for numbers? guess not.
Copy link to clipboard
Copied
I thought spry had a form validation criteria for a text field for numbers?
Yes spry does have telephone syntax validation but you may not know that users can circumvent the validation simply by disabling javascript on their browser. FYI server side validation can not be circumvented.
I thought spry had a forum for asking about validation criteria for a text field for numbers.
FYI this is the Dreamweaver Application Development forum, not the spry forum
Copy link to clipboard
Copied
i'm sure this user isn't building a mission critical application, and although there are some people that may turn off javascript, javascript is a common practice used to validate forms. You know this, but you just like to cause problems and make yourself feel smart. Adobe provides spry validation in Dreamweaver for a reason. This is a Dreamweaver forum - it's important to remember your audience when providing advice. I did provide an alternative php version so I think this topic has been covered. Thank you for adding your input.