Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Input text validation in product_info.php?


Pauliina4

Recommended Posts

Posted

I have a problem again...how to check if field is empty in products attributes?

 

I have installed a contribution which allows me to add text field as an attribute, but now I cant get work customers input validation.

 

What are the main points of doing this?

 

I know I need to add form check to the page:

 

 include('includes/form_check.js.php');

 

->Take user input and name it as an $attribute

 

->Checking if attribute lenght is more than 2 characters:

 

 if (strlen($attribute) < 2) {
     $error = true;

     $messageStack->add('productinfo', ENTRY_ATTRIBUTE_ERROR);
   }

 

->Add the error output:

 

<?php
 if ($messageStack->size('productinfo') > 0) {
?>
     <tr>
       <td><?php echo $messageStack->output('productinfo'); ?></td>
     </tr>

<?php
 } 
?>

 

->And finally add button which updates the page and checks if there is errors (I'm not sure about this phase at all...):

 

<td align="right"><?php echo tep_draw_hidden_field('action', 'process') . tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>

 

Are these phases correct? Is there something else to do? Do I have to modify the form_check.js.php - file?

 

Regards,

 

Pauliina

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...