Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Marcelo Retana
2,534 PointsRegex: only numbers with HTML5 (?)
Hi guys, I want to use only numbers here
<input type="text" placeholder="" class="tel" id="placePhone" name="place[phones]" pattern="[0-9]">
I have it that way but I am not pretty sure of what I am doing. And also I need a max length of 15 digits.
2 Answers

Marcelo Retana
2,534 PointsA friend shows me this:
pattern="\d{1,15}"
will be right?
Remember what I need is only digits and a max-length of 15 digits.

Kenan Memis
47,314 PointsHi,
Your solution is usable but it allows user to enter more than 15 characters.
For maximum length html5 has an attribute => maxlength="15" and for only numbers you can use the pattern which you also used with a regular expression.
Solution could be:
<input type="text" placeholder="" class="tel" id="placePhone" name="place[phones]" maxlength="15" pattern="\d*">