Results 1 to 10 of 15

Hybrid View

  1. #1
    Join Date
    Mar 2006
    Posts
    191
    Plugin Contributions
    0

    bug [Done 1.3.9b] Minimum value of zero gets validated incorrectly in JS formcheck

    Hi, I've touched on this elsewhere previously on the end of a thread that seems to be dead so I've posted here in case someone can help.

    I'm trying to disable validation on the Post Code field. The method suggested around the forums does not work: Setting the minimum value to zero still causes validation on the field by alerting that it requires "zero" characters.

    If I leave the field completely blank, it works (doesn't validate) but then the browser reports a syntax error on the page, because it expects a character where there is none.

    I've now also checked the bug-fix lists for ZC 1.35 and 1.36 but can't see anything resembling this. I'm running 1.302.

    Any help is much appreciated!
    Rob

  2. #2
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Minimum value of zero gets validated incorrectly in JS formcheck

    in the jscript_form_check.php file for the create-account and login pages, you can make one small adjustment (insert the line indicated) to work around this.

    Code:
    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;
        }
      }
    }
    becomes
    Code:
    function check_input(field_name, field_size, message) {
      if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
        if (field_size == 0) return;
        var field_value = form.elements[field_name].value;
    
        if (field_value == '' || field_value.length < field_size) {
          error_message = error_message + "* " + message + "\n";
          error = true;
        }
      }
    }

    This may or may not be the final solution, but will at least function as a workaround.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Mar 2006
    Posts
    191
    Plugin Contributions
    0

    Default Re: Minimum value of zero gets validated incorrectly in JS formcheck

    That's the stuff, thanks DrByte
    I'll detail what I've done now so that others looking for the same thing can find it here.

    To disable Post Code validation in cases where this field is not essential or required, one normally sets Admin, Configuration, Minimum Values, Post Code = 0.

    This is a common requirement in New Zealand where people usually have no idea what their post code is and to top it off the postal service recently changed them all around in order to improve their own internal processes at the cost of everyone else'.

    Because this doesn't work properly in 1.302 and presumably also in 1.35 and 1.36, apply the fix DrByte has given. There may be other files that need this, but I've so far only found these ones:

    In these files
    • includes/modules/pages/account_edit/jscript_form_check.php (line 31)
    • includes/modules/pages/create_account/jscript_form_check.php (line 31)
    • includes/modules/pages/login/jscript_form_check.php (line 31)
    • includes/modules/pages/address_book_process/jscript_main.php (line 31)
    • includes/modules/pages/checkout_shipping_address/jscript_main.php (line 38)
    • includes/modules/pages/checkout_payment_address/jscript_main.php (line 38)


    Add the red bit below to the check_input function at the line indicated:

    function check_input(field_name, field_size, message) {
    if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
    if (field_size == 0) return;
    var field_value = form.elements[field_name].value;


    Now if the Minimum value is set to zero, the form will validate correctly for the pages listed.

    An additional interface fix is to remove the red asterisk next to the field so that the customer knows it is not required.

    In file includes/languages/english.php
    Remove the asterisk in line 219:
    Remove asterisk from: define('ENTRY_POST_CODE_TEXT', '*');

    These changes are not safe from a cart upgrade, but if you check after upgrading, they may no longer even be needed.

    Regards,
    Rob

  4. #4
    Join Date
    Nov 2007
    Posts
    41
    Plugin Contributions
    0

    Default Re: Minimum value of zero gets validated incorrectly in JS formcheck

    This helped tons! ...even a year later...thanks.

  5. #5
    Join Date
    Mar 2006
    Posts
    191
    Plugin Contributions
    0

    Default Re: Minimum value of zero gets validated incorrectly in JS formcheck

    Great to hear... has it been a year already!? ouch!

  6. #6
    Join Date
    Jun 2008
    Location
    Warrenpoint, United Kingdom
    Posts
    44
    Plugin Contributions
    0

    Default Re: [Done 1.3.7, 1.3.9] Minimum value of zero gets validated incorrectly in JS formch

    In the republic of Ireland we dont have postcodes which can put customers off registering so this thread was a great help,

    but I've noticed that when you update a customer from admin such as approving a customer it still requires the postcode.

    I tried to work my way round this and so I edited the following files by adding in the code

    if (field_size == 0) return;

    into

    includes\form_check.js.php (line 21) and
    admin\customers.php (line 380)

    It seems to work but I'm just wondering if anyone can see any way this would cause any problems or pose any risks?

 

 

Similar Threads

  1. v153 Telephone number gives error when minimum value is any number above zero
    By Graniteman22 in forum General Questions
    Replies: 21
    Last Post: 8 Oct 2014, 05:38 AM
  2. v150 Database updated incorrectly when Gift Certificate covers order value?
    By boardshorts in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 3
    Last Post: 25 Dec 2013, 03:00 AM
  3. Value of main_page being returned incorrectly
    By badarac in forum General Questions
    Replies: 7
    Last Post: 7 Oct 2010, 06:42 PM
  4. Replies: 5
    Last Post: 16 Jan 2009, 10:05 AM
  5. Replies: 4
    Last Post: 14 Jan 2009, 11:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg