Hi Bob/Max. I need help in the CSSV. I am not sure if it is the CSSV that is not working or my code. I have a drop down list that I need to validate based on the data entered in the textbox but somehow the CSSV validation doesn't work. The validation below just bypass and go straight to the next page if I selected Category=1-999 and entered a project cost = 8888, which I dont want to happen. I also have a validation to check if the login user already entered the category he selected in the first page. Please help. I am stuck on this and I need to fix it as soon as possible. Attached is my form. Thanks in advance.
My validations that are not working:
1. the Category Level selected should not be less than or greater than the number in each level
2. if category selected exist in database, principal should not allow to enter the same category. (ie.
Somehow, the validation below is not working in the CSSV. It is bypassing it and go straight to the Thank You message. I am using the multi page form in v4. PLease help. I really need this to work as soon as possible. Thanks.
My HTML code for category and project_cost
My validations that are not working:
1. the Category Level selected should not be less than or greater than the number in each level
2. if category selected exist in database, principal should not allow to enter the same category. (ie.
1. Category: 1-999 should not be less than 1 or equal to 999 in the project_cost.
2. once the user selected a category, I want to check if the registered user already entered the category level to the database. If the user does, return an alert message and will not allow them to enter the same category.
Somehow, the validation below is not working in the CSSV. It is bypassing it and go straight to the Thank You message. I am using the multi page form in v4. PLease help. I really need this to work as soon as possible. Thanks.
<?php
$error_exists = false;
$category_code = JRequest::getString('category_code', '', 'post');
$project_cost = JRequest::getString('project_cost', '', 'post');
//check if category level and project cost is equal
if ($category_code == "1-999" && $project_cost < 1 && $project_cost > 999)
{
$form->validation_errors['project_cost'] = 'You selected Level 1: $1-$999 in the Category Level. Project estimated cost amount should not be less than $1.00 and greater than $999.00. Please revise your entry or use the right Category Code.';
$error_exists = true;
}
elseif ($category_code == "1000-9999" && $project_cost < 1000 && $project_cost > 9999)
{
$form->validation_errors['project_cost'] = 'You selected Level 2 in the Category Level. Project estimated cost amount should not be less than $1,000 and greater than $9,999.00. Please revise your entry or use the right Category Code.';
$error_exists = true;
}
elseif ($category_code == "10000-99999" && $project_cost < 10000 && $project_cost > 99999)
{
$form->validation_errors['project_cost'] = 'You selected Level 3 in the Category Level. Project estimated cost amount should not be less than $10,000 and greater than $99,999.00. Please revise your entry or use the right Category Code.';
$error_exists = true;
}
elseif ($category_code == "250000plus" && $project_cost < 250000)
{
$form->validation_errors['project_cost'] = 'You selected the Dream Project in the Category Level. Project estimated cost amount should not be less than $250,000. Please revise your entry or use the right Category Code.';
$error_exists = true;
}
// Get user object -information from Joomla
$user= JFactory::getUser();
$name=$user->name;
$db =& JFactory::getDBO();
$query = "
SELECT `name`, `category_code`
FROM `#__chronoforms_data_principal_project`
WHERE `name` = '{$name}' && `category_code` = '{$category_code}'";
$db->setQuery($query);
$data = $db->loadResult();
if ($data) {
return 'Sorry, the Category you selected already exists in the database. You are allowed to enter only one project for each category.';
print_r ($data);
$error_exists = true;
}
return !$error_exists;
?>
My HTML code for category and project_cost
<div class="formfield" id="autoID-a4668c617f57df750cb17fca9d17796b_container_div">
<label for="category_code">Category Code:</label>
<select size="1" id="category_code" class=" validate['required']" title="" name="category_code">
<option value="">Category is required.</option>
<option value="" selected="selected">Select Category</option>
<option value="1-999">Level 1: $1-$999</option>
<option value="1000-9999">Level 2: $1,000-$9,999</option>
<option value="10000-99999">Level 3: $10,000-$99,999</option>
<option value="250000plus">Dream Project: $250,000+</option>
</select>
<div class="clear"></div>
<div id="error-message-category_code"></div>
</div>
<div class="formfield" id="autoID-7d8a4d57407a7db380e5a6fd7035e92c_container_div">
<label for="project_cost">Project Estimated Cost: $</label><input id="project_cost" maxlength="150" size="30" class=" vvalidate['required','digit','number']" title="" type="text" value="" name="project_cost" />
<div class="clear"></div>
<div id="error-message-project_cost"></div>
</div>