Format Phone Numbers on Contact Form

Options
mwills
mwills Member Posts: 2

I have a phone number entry on my contact form, but would like to make it structured (777777777 vs 777-777-7777). Does anyone have experience with this?

Tagged:

Best Answer

  • Thomas_Connery
    Thomas_Connery Member Posts: 230 MVP
    Answer ✓
    Options

    Hi @mwills, try editing the html portion of the contact form. Look for something like:

    <input type="tel" name="dmform-7" placeholder="Phone" id="123456789" class=""/>

    Then add the following: pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}"

    End result will be:

    <input type="tel" pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}" name="dmform-7" placeholder="Phone" id="123456789" class=""/>

    See if that works for your needs. You may want to add a label that instructs the visitor to enter a ###-###-#### number combination or the form won't allow the submission. Good luck!