SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Nov 2008
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy osCommerce: adding a radio button for delivery time, how to do the validation?

    Dear all,

    I'm new to os commerce and trying to customize the order form...

    I wish to add a radio button where customer get to choose whether to send the order to receiver in the morning or afternoon.

    so i do like below...


    PHP Code:
    <?php echo tep_draw_radio_field('delivery_time''m'$morning) . '&nbsp;&nbsp;' MORNING '&nbsp;&nbsp;' tep_draw_radio_field('delivery_time''a'$afternoon) . '&nbsp;&nbsp;' AFTERNOON '&nbsp;' . (tep_not_null(ENTRY_DELIVERY_TIME_TEXT) ? '<span class="inputRequirement">' ENTRY_DELIVERY_TIME_TEXT '</span>'''); ?>

    The problem is.. I don't get to do validation whether the radio button is selected as I wish to make it a required field. I also having problem to keep the selection to session..

    Can anyone please guide me?

    Thanks!

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Sunny,

    Welcome to the Sitepoint forums!

    Order page means where? Checkout shipping or Checkout payment?

    Though I am also not guru on this osCommerce, whichever the file/page is, see where the form has been posted and processed, then you can validate it there.

    BTW, validation - server side or client side?
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  3. #3
    SitePoint Member
    Join Date
    Nov 2008
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear rajug,

    Thanks so much for your reply..

    I'm adding the script to checkout_shipping.php

    From my understanding, I should add something inside this code(same file- checkout_shipping.php) to make the validation work, however I failed to get it work...

    if ( isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process') ) {
    Do you have any idea?

  4. #4
    SitePoint Member
    Join Date
    Nov 2008
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Between, I'm trying to do validation to some other text field that I added to the checkout_shipping.php.

    The input field:
    <?php echo tep_draw_input_field('delivery_date', $delivery_date) . '&nbsp;' . (tep_not_null(ENTRY_DELIVERY_DATE_TEXT) ? '<span class="inputRequirement">' . ENTRY_DELIVERY_DATE_TEXT . '</span>': ''); ?>

    The validation part:
    if (strlen($delivery_date) <1) {
    $error = true;
    //die("no delivery date");
    $messageStack->add('checkout_address', ENTRY_FIRST_NAME_ERROR);
    }
    However, if the delivery_date is empty, the form still can go through when the die("no delivery date"); is commented. When I let the die("no delivery date"); runs on the script, error message "no delivery date" will be shown.

    Do you think the problem occurs at $messageStack->add('checkout_address', ENTRY_FIRST_NAME_ERROR); or I have missed out anything to make the validation works?

    Please share your opinion... I don't know how to proceed now..


Bookmarks

Posting Permissions

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