I have the following code. I wanted to determine if the value inputted in $cellno (from a textbox) are all digits (numbers), and if it's 11 numbers, and if its starting numbers are "09".

One correct value example is 09345678910. It is all numbers, has 11 digits, and begins in 09.

By the way, I got this error upon executing my code:
Parse error: syntax error, unexpected '[' in C:\xampp\htdocs\GWS\cusdet.php on line 26

Please help!!! Super, super, duper newbie here. :( Thanks in advance!!

<input id="cellno" type="text" placeholder = "Enter Cellphone Number" size = "20">
    $cellno = document.getElementById('cellno').value;
    $corcellno = 09;

<input type="submit" name="Submit" value="     Next     " onClick="
        echo "if (strcasecmp($cellno, $corcellno, 2) == 0){";
                echo "if (strlen($cellno == 11) && preg_match("/[0-9]/", $cellno)";
                    echo "window.location.href='dismet.php';}";
        echo "else";
            echo "alert('Sorry. You must input a valid cellphone number that contains 11 digits.');}";                  

In line 10 above, change as below:

 echo "if (strlen($cellno == 11) && preg_match(\"[0-9]\", $cellno)";

What you typed above is not correct...double quote within another double quote can be written as \" (escape sequence)

Thank you very much, Mr. Rajesh. I did changed it already but gave me a new error:

Notice: Use of undefined constant document - assumed 'document' in C:\xampp\htdocs\GWS\cusdet2.php on line 14

Fatal error: Call to undefined function getElementById() in C:\xampp\htdocs\GWS\cusdet2.php on line 14

I don't understand what's wrong. The getElementById() code worked perfectly in my other page, but it doesn't work in this page. Please help!! :( Thanks in advance!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.