Guest Posted April 25, 2004 Posted April 25, 2004 How can I edit this section of the catalog/create_account.php form to remove the required field for the telephone number and just leave in the form field: <tr> <td class="main"><?php echo ENTRY_TELEPHONE_NUMBER; ?></td> <td class="main"><?php echo tep_draw_input_field('telephone') . ' ' . (tep_not_null(ENTRY_TELEPHONE_NUMBER_TEXT) ? '<span class="inputRequirement">' . ENTRY_TELEPHONE_NUMBER_TEXT . '</span>': ''); ?> </td> </tr> I want to make the telephone code invalid and keep running into problems. Here is what I've done so far (a lot of work for one thing!): 1. I made the telephone field NULL (yes) in SQL 2. I changed the define fields in catalog/includes/languages/english.php to this: define('ENTRY_TELEPHONE_NUMBER', 'Telephone Number:'); define('ENTRY_TELEPHONE_NUMBER_ERROR', ''); define('ENTRY_TELEPHONE_NUMBER_TEXT', ''); 3. I removed this in catalog/create_account.php: if (strlen($telephone) < ENTRY_TELEPHONE_MIN_LENGTH) { $error = true; $messageStack->add('create_account', ENTRY_TELEPHONE_NUMBER_ERROR); } 4. I made the minimum for the phone field 0 in the Admin panel (if I make a blank space instead of the value zero, then it generates an error in Internet Explorer 6). Now I'm generating this error: Errors have occurred during the process of your form. Please make the following corrections *
stevel Posted April 25, 2004 Posted April 25, 2004 I'm not exactly sure what you're looking for. Do you simply want to make it as if the telephone is never asked for? Here's the simplest way I know of to do that. Replace the code you posted that outputs the phone prompt with this: <?php echo tep_draw_hidden_field('telephone', ''); ?> and set the minimum length to 0 in admin. Leave the rest alone. Remember to do this in includes/modules/address_book_details.php too. Steve Contributions: Country-State Selector Login Page a la Amazon Protection of Configuration Updated spiders.txt Embed Links with SID in Description
Guest Posted April 25, 2004 Posted April 25, 2004 Hi Steve, I found that changing the minimum to 0 prompted a javascript that still insisted on a phone entry. The way that I had to get rid of errors and prompts was to delete the phone number from the minimum requirement in the Admin panel and to delete all instances of the requirement for the field in each .php page. I did a search and found the related pages. Here is what I did and it seems to work: Removing Required Phone Field: 1. Delete the Phone Number field from the Minimum listing in the Admin Panel. This is how: - Open sql database - Enter Configuration (Click to Browse information) - Delete ID 28 (Phone Number) 2. Search for and remove all instances of TELEPHONE_MIN_LENGTH, including the following code: if (strlen($telephone) < ENTRY_TELEPHONE_MIN_LENGTH) { $error = true; $messageStack->add('create_account', ENTRY_TELEPHONE_NUMBER_ERROR); } in the following files: - catalog/account_edit.php - catalog/create_account.php - catalog/includes/form_check.js.php - catalog/admin/customers.php 3. Remove the asterisk (*) from the page that customers view, indicating that it's a required field, AND blank out the error text. Copy-and-paste the code below to replace your existing code: define('ENTRY_TELEPHONE_NUMBER', 'Telephone Number:'); define('ENTRY_TELEPHONE_NUMBER_ERROR', '' . ENTRY_TELEPHONE_MIN_LENGTH . ' characters.'); define('ENTRY_TELEPHONE_NUMBER_TEXT', ''); in the following file: - catalog/includes/languages/english.php (other languages as needed) (You should be able to leave catalog/admin/includes/languages/english.php and corresponding language files as they are; no changes should be needed.)
Guest Posted April 25, 2004 Posted April 25, 2004 Steve - FYI - There is no occurrence of telephone or TELEPHONE in this file: includes/modules/address_book_details.php
♥yesudo Posted April 25, 2004 Posted April 25, 2004 Look in includes/form_check.js.php: check_input("telephone", <?php echo ENTRY_TELEPHONE_MIN_LENGTH; ?>, "<?php echo ENTRY_TELEPHONE_NUMBER_ERROR; ?>"); Your online success is Paramount.
nesincg Posted July 7, 2004 Posted July 7, 2004 For anyone still getting the javascript error (...must contain a minimum of 0 characters), yesudo was on the right track, but I fixed the javascript instead of going around it. Find this javascript function in includes/form_check.js.php function check_input(field_name, field_size, message) { ?if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) { ? ?var field_value = form.elements[field_name].value; ? ?if (field_value == '' || field_value.length < field_size) { ? ? ?error_message = error_message + "* " + message + "\n"; ? ? ?error = true; ? ?} ?} } On the second line, add: && (field_size > 0) So the function will look like this: function check_input(field_name, field_size, message) { ?if (form.elements[field_name] && (form.elements[field_name].type != "hidden") && (field_size > 0)) { ? ?var field_value = form.elements[field_name].value; ? ?if (field_value == '' || field_value.length < field_size) { ? ? ?error_message = error_message + "* " + message + "\n"; ? ? ?error = true; ? ?} ?} } Now the function checks first to see if the required size is 0, and skips it if true. I hope that helps someone. :huh:
iamkim Posted September 8, 2004 Posted September 8, 2004 That's great! I noticed though that if I edit a customer's profile in the admin section, that I am then required to add a phone number with a minimum value of 0. Is there a corresponding file in the admin section I should alter as well? Thanks in advance! Building the web - One Site at A Time
Recommended Posts
Archived
This topic is now archived and is closed to further replies.