Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

nrao wwwxxx, xxxxxdup, procmail change subject header, wwwXxx not20, Wwwxxx.doks sas, linux raid resync after reboot, bind-address mysql multiple, sanibleone xxxx, ftp://192.168.100.100/, www.xxxcon

Links

XODOX
Impressum

#1: Validating a field for correct input

Posted on 2008-04-16 10:02:45 by Rick Wright

GlacierHi -

I need to validate a field in my database where the user will input their
phone number. I would like to ensure that the area code is included. The
field is setup as follows:

hphone varchar(12)

What is the best way to check to see if this format 123-456-7890 is entered?
Thank you in advance for any assistance.

- Rick

Report this message

#2: Re: Validating a field for correct input

Posted on 2008-04-16 11:12:59 by Captain Paralytic

On 16 Apr, 08:02, "Rick Wright" <rbw95...@gmail.com> wrote:
> GlacierHi -
>
> I need to validate a field in my database where the user will input their
> phone number. I would like to ensure that the area code is included. The
> field is setup as follows:
>
> hphone varchar(12)
>
> What is the best way to check to see if this format 123-456-7890 is entered?
> Thank you in advance for any assistance.
>
> - Rick

How will the user get their data into the table? Since you are posting
in alt.php.sql, I assume it is through some sort of php driven web
form.

So use a REGEX in either javascript and/or php to verify the format
before loading it into the table.

Report this message

#3: Re: Validating a field for correct input

Posted on 2008-04-16 15:47:23 by Larry Anderson

On Apr 16, 1:02 am, "Rick Wright" <rbw95...@gmail.com> wrote:
> GlacierHi -
>
> I need to validate a field in my database where the user will input their
> phone number. I would like to ensure that the area code is included. The
> field is setup as follows:
>
> hphone varchar(12)
>
> What is the best way to check to see if this format 123-456-7890 is entered?
> Thank you in advance for any assistance.
>
> - Rick

Here ya go. I had to look for one a while back.

<?php
function checkPhone($number){
if(ereg("^[0-9]{3}-[0-9]{3}-[0-9]{4}", $number)) {
return true;
} else {
return false;
}
}
?>

Report this message

#4: Re: Validating a field for correct input

Posted on 2008-04-16 20:11:25 by unknown

Post removed (X-No-Archive: yes)

Report this message