Check for consecutive numbers/letters
Posted: Wed Jul 19, 2006 5:55 pm
Weirdan | Please use
The problem is, it ALWAYS returns Invalid no matter what number I use
Any ideas? As a follow up, I'd like to do this for numbers to.
Many thanks!
Weirdan | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello,
I'm trying to prevent against users entering consecutive numbers in the phone number, and consecutive letters in the first and last name on a form.
I want to prevent a user from typing 717-222-3124 or 717-531-1111 (as examples)
Here's what I have for the phone numbers.Code: Select all
$phone1 = 717
$phone2 = 818
$phone3 = 3040
$pattern1 = "/^\d{3}$/";
$pattern2 = "/\d{4}/";
if (preg_match($pattern1, $phone2, $matches)) {
echo "$phone2 Phone 2 Invalid<br>";
}
else {
echo "$phone2 Phone 2 Valid<br>";
}
if (preg_match($pattern2, $phone3, $matches)) {
echo "$phone3 Phone 3 Invalid<br>";
}
else {
echo "$phone3 Phone 3 Valid<br>";
}Any ideas? As a follow up, I'd like to do this for numbers to.
Many thanks!
Weirdan | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]