Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to validate a phone number and make sure the user enters all 10 digits. This can be done using the HTML5 pattern atribute:

<input pattern=".{10,}" title="10 characters minimum">

How can I add this pattern attribute to my input tag in Contact Form 7 ?

This what the mobile number input shortcode looks like:

[text* mobile id:field-mobile]

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You can use a tel shortcode to do this:

[tel* id:field-mobile 10/10 "placeholder text"]

This brings up the issue of browser support; if the browser in use does not support the tel input type, it will fall back to a plain text field.

Source: http://contactform7.com/text-fields/ (halfway down the page)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.