Log in

View Full Version : Is there a way to do an input mask?


JoshFink
06-11-2002, 03:31 PM
I want to have a profile field for Phone Numbers.

I want the phone numbers to be in the format (xxx) xxx-xxxx

I'm curious on how I would do this.

Thanks for the help

Josh

Admin
06-11-2002, 04:48 PM
See this in register.php and member.php:
// ENTER ANY CUSTOM FIELD VALIDATION HERE!
Put there preg_match statement, and see if the $$varname fits the pattern:
#\([0-9]{3}\) [0-9]{3}-[0-9]{4}#

JoshFink
06-11-2002, 04:53 PM
Thanks, but wouldn't that REQUIRE them to enter in the correct format?

Is there a way so that they just enter 10 digits and it displays it like that?

Thanks

Josh

Admin
06-11-2002, 05:22 PM
How do you expect them to enter it?
xxx xxx-xxxx
xxxxxx-xxxx
xxx xxx xxxx
??

Chris M
06-11-2002, 06:16 PM
Probably just :

xxxxxxxxxx

Satan

JoshFink
06-11-2002, 06:21 PM
xxxxxxxxxx

Should be fine. I think it would be the easiest to format.

Thanks

josh

Admin
06-12-2002, 05:21 AM
In register.php and member.php replace this:
$$varname=censortext($$varname);
// ENTER ANY CUSTOM FIELD VALIDATION HERE!
With this:
$$varname=censortext($$varname);
if ($profilefield['profilefieldid'] == XX and preg_match('#[0-9]{10}#', $$varname)) {
$$varname = '('.substr($$varname, 0, 3).') '.substr($$varname, 3, 3).'-'.substr($$varname, 6);
}
// ENTER ANY CUSTOM FIELD VALIDATION HERE!
(Without the spaces; quote this message to see the real source)

JoshFink
06-12-2002, 01:15 PM
Thanks for the help, I'll give it a try.

Josh

Chris M
06-12-2002, 05:13 PM
Did it work?

Satan