Jump to content

JavaScript Phone (only numbers)


Recommended Posts

Hi, I need a little help,

I'm not very good in programming tho (My one of the serious attempt:P)

How do I aplly only numbers? (max. 10)

if (document.formulier.telefoonnummer.value == "") {
document.getElementById('telefoonnummer').innerHTML = "please insert your phonenumber";
document.getElementById('8').innerHTML = "!";
}
else
{
if (document.formulier.telefoonnummer.value.length < 10) {
document.getElementById('telefoonnummer').innerHTML = "please insert a valid phonenumber!";
document.getElementById('8').innerHTML = "!";

What shall I do?

Thanks and sorry for bad English :P

Link to comment
Share on other sites


Check out this page for your reference.

I think it has what you need to accomplish your needs.

Advanced JavaScript Stuff

You might want to use the

parseInt() and isNaN() functions or whatever you call them inorder to check if it is a number or not.

and

if your numbers, since its a phone number, might include hiphens "-" and / or "(", ")" inside them, use the str.replace() function to accomplish it.

Have Fun!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...