# Phone number validation, indexOf

**URL:** <https://forum.kirupa.com/t/phone-number-validation-indexof/193982>\
**Category:** Uncategorized\
**Created:** [July 19, 2006, 6:20pm UTC](https://forum.kirupa.com/t/phone-number-validation-indexof/193982 "2006-07-19T18:20:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jerryj](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@jerryj](https://forum.kirupa.com/u/jerryj)\
**Post date:** [July 19, 2006, 6:20pm UTC](https://forum.kirupa.com/t/phone-number-validation-indexof/193982/1 "2006-07-19T18:20:51Z")

</div>

Hello,

I need some help with validating a phone number. I want to check if the length of the number is ten chars and if the first number is a “0” and the second number a “6”.

This is my code so far.

```auto
form.send.onRelease = function() {
    yournumber = form.number.text;
    if (yournumber == null || yournumber == ""){
        trace ("no number");
    }
    if (yournumber.length !=10|| yournumber.indexOf("0") == -1 || yournumber.indexOf("6") == -1) {
        trace ("non existent number");
    }
}

```

This only checks if there is a “0” and a “6”, but not if they are the first and second char in the string.

Thanks for your help!

Jerryj.
