Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

how to modify categories.php to get warning message when I leave blank in any textboxes


nothinhill

Recommended Posts

Posted

Adding a new product in any category and I leave blank in any of textboxes ( Tax Class: ,Products Price (Net), Products Price (Gross),Products Description ,Products Quantity,Products Model) . An Error is occured due to leaving blank in any textboxes "Out of range value adjusted for column "

 

I think any of textboxes is left blank . System should give warning message .Or some textboxes should be optional to be filled (as Member can be register to oscmmmerce and some of textboex is left blank in login page. Warning message box is displayed to be filled required textboxes.It was written in java script ).How can I modify page categories.php to get warning message like login page

Posted
Adding a new product in any category and I leave blank in any of textboxes ( Tax Class: ,Products Price (Net), Products Price (Gross),Products Description ,Products Quantity,Products Model) . An Error is occured due to leaving blank in any textboxes "Out of range value adjusted for column "

 

I think any of textboxes is left blank . System should give warning message .Or some textboxes should be optional to be filled (as Member can be register to oscmmmerce and some of textboex is left blank in login page. Warning message box is displayed to be filled required textboxes.It was written in java script ).How can I modify page categories.php to get warning message like login page

 

 

please any help This is so important for me????

  • 1 year later...
Posted
Adding a new product in any category and I leave blank in any of textboxes ( Tax Class: ,Products Price (Net), Products Price (Gross),Products Description ,Products Quantity,Products Model) . An Error is occured due to leaving blank in any textboxes "Out of range value adjusted for column "

 

I think any of textboxes is left blank . System should give warning message .Or some textboxes should be optional to be filled (as Member can be register to oscmmmerce and some of textboex is left blank in login page. Warning message box is displayed to be filled required textboxes.It was written in java script ).How can I modify page categories.php to get warning message like login page

 

I was trying to get a solution to this myself.

 

This might not be the most sophisticated solution, but it seemed to work for me:

 

This is an example for the 'Model' Field and can be adapted for any field you like.

 

In admin/categories.php

 

just before

$action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

 

add

  if (isset($HTTP_GET_VARS['action']) && $HTTP_GET_VARS['action'] == 'new_product_preview') {
	if($HTTP_POST_VARS['products_model'] == '' || strlen($HTTP_POST_VARS['products_model']) < '5' ||  !is_numeric($HTTP_POST_VARS['products_model'])) {
   $HTTP_GET_VARS['action'] = 'new_product';
   $messageStack->add(ERROR_FIELD_REQUIRED, 'error');
  } 
 }

 

 

strlen($HTTP_POST_VARS['products_model']) < '5'

Is optional but usefull if you want to set a minimum leght for the field.

 

!is_numeric($HTTP_POST_VARS['products_model'])

Is also optional. Use this when you want to limit the model field to numbers only. Don't use this for any field where you need text (e.g. name or description)

 

 

Don't forget to add your Error messages to the corresponding language files.

 

e.g. in admin/includes/languages/english/categories.php

 

add

define('ERROR_FIELD_REQUIRED', 'Error: Please complete all required fields.');

 

 

I don't know if you still need this, since your post is from january. But as my search for a solution came to no avail, I thought it won't hurt posting it.

 

regards

Patrick

Archived

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

×
×
  • Create New...