fasiso Posted February 23, 2006 Posted February 23, 2006 Dear Friends I need that the telephone field only alow numbers in create_account.php? How can I get it? Thanks in advance.
MartinM Posted February 23, 2006 Posted February 23, 2006 Dear Friends I need that the telephone field only alow numbers in create_account.php? How can I get it? Thanks in advance. Try this: find the following lines in create_account.php if (strlen($telephone) < ENTRY_TELEPHONE_MIN_LENGTH) { $error = true; $messageStack->add('create_account', ENTRY_TELEPHONE_NUMBER_ERROR); } After them, add: if (!preg_match('/^[\d\s]+$/',$telephone)){ $error = true; $messageStack->add('create_account', ENTRY_TELEPHONE_NOT_NUMBER); } Then edit catalog/includes/languages/english.php, and add the line define('ENTRY_TELEPHONE_NOT_NUMBER', 'Your Telephone Number must contain only numbers'); Add something equivalent to your other language files if needed. Note that this will allow both numbers and spaces - if you want numbers only, just get rid of the "\s"
Zuncan Posted April 20, 2006 Posted April 20, 2006 Hi! This is just the thing I need. Problem is that I allow my customers to leave the phonefield blank, but this code forces the phonenumber to be filled in. How can I alter this code so that it doesnt give a errormessage if the field is left blank? if (!preg_match('/^[\d\s]+$/',$telephone)){ $error = true; $messageStack->add('create_account', ENTRY_TELEPHONE_NOT_NUMBER); } Greatful for help / Zuncan So what?! Who care in a hundred years anyway?
♥Monika in Germany Posted April 20, 2006 Posted April 20, 2006 Hi! This is just the thing I need. Problem is that I allow my customers to leave the phonefield blank, but this code forces the phonenumber to be filled in. How can I alter this code so that it doesnt give a errormessage if the field is left blank? if (!preg_match('/^[\d\s]+$/',$telephone)){ $error = true; $messageStack->add('create_account', ENTRY_TELEPHONE_NOT_NUMBER); } Greatful for help / Zuncan Hi Zuncan, try this if (!preg_match('/^[\d\s]+$/',$telephone)){ if ($telephone != ''){ $error = true; $messageStack->add('create_account', ENTRY_TELEPHONE_NOT_NUMBER); } } :-) Monika addicted to writing code ... can't get enough of databases either, LOL! my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum Interactive Media Award July 2007 ~ category E-Commerce my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...
Zuncan Posted April 20, 2006 Posted April 20, 2006 Thanks for your time Monica, Worked perfect! /Zuncan So what?! Who care in a hundred years anyway?
Recommended Posts
Archived
This topic is now archived and is closed to further replies.