Forum Moderators: open

Message Too Old, No Replies

Checking input box for certain numeric characters

A telephone number area code check.

         

WibbleWobble

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?

txbakers

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

WebmasterWorld Senior Member 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.

WibbleWobble

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)