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:
PHP Code:
// 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
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
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
PHP Code:
<fieldset>
<legend><?php echo TABLE_HEADING_COMMENTS; ?></legend>
<?php echo zen_draw_textarea_field('comments', '45', '3'); ?>
</fieldset>
Would love some assistance.
Cheers
Lee
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:
PHP Code:
<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:
PHP Code:
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
Re: text field area on step 1 of 3 page
Ok this seems to work:
PHP Code:
' 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
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