Forums / Templates, Stylesheets, Page Layout / text field area on step 1 of 3 page

text field area on step 1 of 3 page

Locked

Started by multichild on 10 Jan 2008, 1:47 PM · Views: 1,196

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
10 Jan 2008, 1:47 PM
#1
multichild avatar

multichild

Zen Follower

Join Date:
Sep 2007
Location:
Chepstow, SE Wales
Posts:
101
Plugin Contributions:
0

text field area on step 1 of 3 page

I need to make that text are field on step 1 of 3 page mandatory, and i also need to add some shadow text in there to describe what I need from the customer.

I think I tracked the function down to html_output.php page, and this function below, but not too sure:

// Output a form textarea field
  function zen_draw_textarea_field($name, $wrap, $width, $height, $text = '', $parameters = '', $reinsert_value = true) {
    $field = '<textarea name="' . zen_output_string($name) . '" wrap="' . zen_output_string($wrap) . '" cols="' . zen_output_string($width) . '" rows="' . zen_output_string($height) . '"';

    if (zen_not_null($parameters)) $field .= ' ' . $parameters;

    $field .= '>';

    if ( (isset($GLOBALS[$name])) && ($reinsert_value == true) ) {
      $field .= stripslashes($GLOBALS[$name]);
    } elseif (zen_not_null($text)) {
      $field .= $text;
    }

    $field .= '</textarea>';

    return $field;
  }

could somebody help me with this.

Thanks

Lee

Are we there yet?

Just one more line of code and im done...

11 Jan 2008, 9:30 AM
#2
multichild avatar

multichild

Zen Follower

Join Date:
Sep 2007
Location:
Chepstow, SE Wales
Posts:
101
Plugin Contributions:
0

Re: text field area on step 1 of 3 page

Sorry, I just dont know why I targeted that function when its obviously the wrong one.

But still Im trying to make that text field mandatory, and I need some shadow text inside the textfield to prompt the customer.

With it being mandatory, it needs to alert the customer if no text is entered.

Any ideas anybody

Lee

Are we there yet?

Just one more line of code and im done...

11 Jan 2008, 9:52 AM
#3
multichild avatar

multichild

Zen Follower

Join Date:
Sep 2007
Location:
Chepstow, SE Wales
Posts:
101
Plugin Contributions:
0

Re: text field area on step 1 of 3 page

This is the code that calls the function for the textarea and its in this folder:
includes/templates/classic/templates/tpl_checkout_payment_default.php

<fieldset>
<legend><?php echo TABLE_HEADING_COMMENTS; ?></legend>
<?php echo zen_draw_textarea_field('comments', '45', '3'); ?>
</fieldset>

Would love some assistance.

Cheers

Lee

Are we there yet?

Just one more line of code and im done...

14 Jan 2008, 12:59 PM
#4
multichild avatar

multichild

Zen Follower

Join Date:
Sep 2007
Location:
Chepstow, SE Wales
Posts:
101
Plugin Contributions:
0

Re: text field area on step 1 of 3 page

Ok i think ive nearly got to the bottom of it, but im inches off i reckon.

Ive found out where the javascript validation takes place to make sure the form is fille din correctly, and using the code below from the tpl_checkout_payment_default.php page:

<fieldset>
<legend><?php echo TABLE_HEADING_COMMENTS; ?></legend>
<?php echo zen_draw_textarea_field('comments', '45', '3'); ?>
</fieldset>

The validation code is on the page payment.php page, and I put the text field validation code inside below:

function javascript_validation() {
    $js = '';
    if (is_array($this->modules) && sizeof($this->selection()) > 0) {
      $js = '<script language="javascript"  type="text/javascript"><!-- ' . "\n" .
      'function check_form() {' . "\n" .
      '  var error = 0;' . "\n" .
      '  var error_message = "' . JS_ERROR . '";' . "\n" .
      '  var payment_value = null;' . "\n" .
	  
	  '  if (document.checkout_payment.comments == "" ) {' . "\n" .
	  '  error_message = error_message + "' . JS_ERROR_NO_TEXT_ENTERED . '";' . "\n" .
	  '  alert(error_message);' . "\n" .
	  '  }' . "\n" . 
	  
      '  if (document.checkout_payment.payment) {' . "\n" .
      '    if (document.checkout_payment.payment.length) {' . "\n" .
      '      for (var i=0; i<document.checkout_payment.payment.length; i++) {' . "\n" .
      '        if (document.checkout_payment.payment[i].checked) {' . "\n" .
      '          payment_value = document.checkout_payment.payment[i].value;' . "\n" .
      '        }' . "\n" .
      '      }' . "\n" .
      '    } else if (document.checkout_payment.payment.checked) {' . "\n" .
      '      payment_value = document.checkout_payment.payment.value;' . "\n" .
      '    } else if (document.checkout_payment.payment.value) {' . "\n" .
      '      payment_value = document.checkout_payment.payment.value;' . "\n" .
      '    }' . "\n" .
      '  }' . "\n\n";

The extra spaced 'if statement' not from the top is my addition, and i think its not looking at the right thing to validate it. My reason for thinking this, is that I took away the if bit and just had the error calling that error description and it worked.

But when i click submit, its not seeing that the field 'comments' has nothing typed into it and bypassing the if statement.

can anybody see my problem.

Lee

Are we there yet?

Just one more line of code and im done...

14 Jan 2008, 5:01 PM
#5
multichild avatar

multichild

Zen Follower

Join Date:
Sep 2007
Location:
Chepstow, SE Wales
Posts:
101
Plugin Contributions:
0

Re: text field area on step 1 of 3 page

Ok this seems to work:

'  if (document.checkout_payment.comments.value == "" ) {' . "\n" .
	  '  error_message = error_message + "' . JS_ERROR_NO_TEXT_ENTERED . '";' . "\n" .
	  '  alert(error_message);' . "\n" .
	  '  }' . "\n" .

I was missing .value on the end

Just an order of alert issue now.

If anybody still feels they can contribute then I would be pleased to talk to you.

Lee

Are we there yet?

Just one more line of code and im done...

28 Apr 2009, 12:24 AM
#6
briskday avatar

briskday

New Zenner

Join Date:
Sep 2007
Posts:
18
Plugin Contributions:
0

Re: text field area on step 1 of 3 page

Thanks multichild!

this was exactly what I was looking for, just had to add "return false" at the end to keep it from advancing.

really appreciate the post