Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

telephone formating

Community Beginner ,
Oct 26, 2009 Oct 26, 2009

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!

TOPICS
Server side applications
687
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 26, 2009 Oct 26, 2009

$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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 26, 2009 Oct 26, 2009
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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 26, 2009 Oct 26, 2009
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines