Formatting a phone number?

Home Forums Quform PHP Formatting a phone number?

This topic is: resolved
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #14573
    Trig
    Participant

    I like the mail from to accept any 10 digit phone number and then in the process.php have the phone number concerted to the format xxx-xxx-xxxx How is this done?

    OR

    On the form side force the user to entering the phone number in the xxx-xxx-xxxx format. How is this done?

    Thank you!

    #14643
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    • This reply was modified 9 years, 8 months ago by Ally.
    #14668
    Trig
    Participant

    Thank you Ally!

    Trig

    #14669
    Trig
    Participant

    Ally,

    One follow-up question. I used your server side fix using a Regex validator. How do I also make $phone a required field?

    Thanks again!

    #14670
    Trig
    Participant

    Never mind, I got it. For anyone else interested in this thread, this works:

    $phone->addValidator('required');

    $phone->addValidator('regex', array('pattern' => '/^[0-9]{3}-[0-9]{3}-[0-9]{4}$/', 'messages' => array('not_match' => 'Please enter the phone number in the format XXX-XXX-XXXX')));

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy