Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,839
    Plugin Contributions
    31

    Default Javascript validation of extra field in create edit account

    Hi,
    I need some pointers regarding Javascript validation.

    I have added a tax id field to the create and edit account pages. I wish to validate this field.

    Using edit account for illustration purposes the core javascript validation routine is
    \includes\modules\pages\account_edit\jscript_form_check.php

    I have added my routine in the same folder
    \includes\modules\pages\account_edit\jscript_form_check_NIF.php

    This is being included and is validating correctly but I have had to modify the core file jscript_form_check.php to call this extra routine during the form validation.

    check_dni("taxid", <?php echo ENTRY_TAXID_NUMBER_LENGTH; ?>, "<?php echo ENTRY_TAXID_NUMBER_ERROR; ?>");

    In the interests of code-elegance/education, is it possible to call this extra routine WITHOUT modifying the core code jscript_form_check.php?
    If so how? I am an educated cut-and-paste trial-and-error coder and not much more, so be gentle.

    Regards
    Steve

  2. #2
    Join Date
    Sep 2004
    Location
    Western Massachusetts
    Posts
    2,945
    Plugin Contributions
    5

    Default Re: Javascript validation of extra field in create edit account

    The easiest way to get this to work without modifying the core jscript file is to duplicate the function check_form in your own jscript file (call it another name like check_my_form), and add your call to the check_dni function within it.

    Then edit override copies of the account_edit, create_account and login templates, changing the onsubmit function to use check_my_form instead of check_form.
    Neville
    An assumption is what you arrive at when you get tired of thinking...

  3. #3
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,839
    Plugin Contributions
    31

    Default Re: Javascript validation of extra field in create edit account

    Thanks for that.

    The only thing "wrong" is that the original jscript_check.form.php gets loaded too (as does any jscript*.) in addition to the new code unless you move it/delete it out of the folder, which sort of defeats the aim of trying to leave original code intact.
    Still, worth a try, you can't have everything I guess.

    regards
    Steve

  4. #4
    Join Date
    Sep 2004
    Location
    Western Massachusetts
    Posts
    2,945
    Plugin Contributions
    5

    Default Re: Javascript validation of extra field in create edit account

    Unless you copy all the individual form field check functions in the original, you actually still need to load it for your custom form check to work...
    Neville
    An assumption is what you arrive at when you get tired of thinking...

  5. #5
    Join Date
    Jul 2010
    Location
    Egypt
    Posts
    48
    Plugin Contributions
    0

    Default Re: Javascript validation of extra field in create edit account

    dear : torvista
    I'm new to zen-cart and i need to do the same (adding new field to create account page )

    can you help plz ?

  6. #6
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,839
    Plugin Contributions
    31

    Default Re: Javascript validation of extra field in create edit account

    this thread will show the way:
    "Add a field into create account"

    http://www.zen-cart.com/forum/showthread.php?t=73181

 

 

Similar Threads

  1. v138a modify edit product page extra field
    By teoB in forum Setting Up Categories, Products, Attributes
    Replies: 4
    Last Post: 3 Oct 2012, 09:18 AM
  2. Extra User Displayed on Create An Account - Success Page
    By Gaterohnn in forum Managing Customers and Orders
    Replies: 6
    Last Post: 19 May 2010, 03:05 AM
  3. Replies: 13
    Last Post: 4 May 2010, 10:47 AM
  4. removing extra required field in account signup
    By newagekat in forum General Questions
    Replies: 11
    Last Post: 9 Aug 2009, 08:16 PM
  5. Edit/Update Account Doesn't Work after Adding a new Account Field
    By webomat in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 19 Apr 2007, 04:51 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