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
Stu Cowley
26,287 PointsHTML input type="number" question
Hey guys,
So I'm on the final page of a project for a client. Basically it's a contact form and where the user inputs their phone number I want there to only be numbers so the user can input their phone number only.
I have built the form and I have used
<input name="phone" id="phone" type="number">
But when I refresh the browser and the input field asking for a phone number will only allow numbers, but there is counter up and down arrows, and this is not what I want.
I have been searching for an answer to this problem on Google but alas I haven't found anything.
Does anyone have any ideas how I can remove this?
Thanking you in advance,
Stu :)
1 Answer
Andrew Corcoran
20,552 PointsHi Stu,
If you want to do this on the client side you could use Javascript or jQuery form validation to achieve the desired result. http://teamtreehouse.com/library/build-an-interactive-website#form-validation-and-manipulation
Just remember that this won't work if the user has Javascript disabled in their browser. If you are looking for something more persistent, you would need server-side validation which PHP would be perfect for. http://teamtreehouse.com/library/enhancing-a-simple-php-application-2