Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Checking input box for certain numeric characters

A telephone number area code check.



12:28 pm on Feb 9, 2004 (gmt 0)

10+ Year Member

I have truly no idea about javascript, so I'll throw this out there in the hope one of you is kind enough to know how to do this.

We have an input box for telephone numbers, and we need to stop people entering mobile numbers when they should enter landline numbers, so we basically need to check if the number begins with 07 when the form is submitted. Can anyone shed any light upon how to do this?


12:37 pm on Feb 9, 2004 (gmt 0)

WebmasterWorld Senior Member txbakers is a WebmasterWorld Top Contributor of All Time 10+ Year Member

if (document.form.field.value.indexOf("07") == 0){
phonenumber begins with 07
} else {
phonenumber doesn't.

That's the basics of it.

look to www.w3schools.com for a good tutorial for javascript.


3:08 pm on Feb 9, 2004 (gmt 0)

10+ Year Member

That seems almost insultingly easy, cheers :))

I've had a look at those tutorials mentioned, but only when the need arises, which is fairly infrequently. Still, I may have another glance-aroon.

(cheers again)


Featured Threads

Hot Threads This Week

Hot Threads This Month