all groups > flash actionscript > december 2004 >
You're in the

flash actionscript

group:

Checking the validity of a mobile number


Checking the validity of a mobile number alwaysabitlost
12/16/2004 11:53:35 PM
flash actionscript:
I have

if (!Name.length) {
feedback = 'Put your name';
}

How would I check to make sure the number someone inputs is 11 digits long and begins with 07?
Re: Checking the validity of a mobile number neuralsea
12/16/2004 11:59:54 PM
Re: Checking the validity of a mobile number Peo
12/21/2004 11:18:41 AM
[quoted text, click to view]

This function returns true if the if the passed "number" (it is in fact a
string) is exactly 11 chars long, and begins with "07", else it returns
false.


function validNumber(number_str) {
/*
first we check wether or not the number_str
is exactly 11 chars long.
*/
if (number_str.length != 11) {
return false;
/* second we check if the first two chars
of the string is "07"
*/
} else if (number_str.substr(0, 2) != "07") {
return false;
/*
If both criterias are met, we return the
boolean value: true
*/
} else {
return true;
}
}

// test the function
test = "07345678901";
trace(validNumber(test));


//peo

AddThis Social Bookmark Button