Thanks for the link!
I actually figured this out just using some simple javascript. The file I edited was:
Code:
Rootofstore/includes/templates/YOURTEMPLATE/templates/"tpl_product_info_display.php".
Keep in mind that this only works with products that have the specific attributes you have to check. In my case, I had a few text fields that needed to be filled ONLY if they checked a certain radio option above those fields.
I added this to the bottom of the file:
Code:
<script language="JavaScript">
new validateForm(document.forms['cart_quantity']);
</script>
At the top of the file, I added the javascript needed to test the form. If you look at the source of your product page, you can find the "name" of the form element that you need to check. The things in red are the things you have to customize. Actually, the conditions themselves you should customize to how you need it:
Code:
<script language="JavaScript" type="text/javascript">
function validateForm(oForm)
{
//oForm refers to the form which you want to validate
oForm.onsubmit = function() // attach the function to onsubmit event
{
if(oForm.elements['attrib-16-107'].checked == false && oForm.elements['id[txt_14]'].value == '')
{
alert("Please enter a name for your Registrant.");
return false;
}
else if(oForm.elements['attrib-16-107'].checked == false && oForm.elements['id[txt_15]'].value == '')
{
alert("Please enter an email for your Registrant.");
return false;
}
else if(oForm.elements['attrib-16-107'].checked == false && oForm.elements['id[txt_21]'].value == '')
{
alert("Please enter a phone number for your Registrant.");
return false;
}
else if(oForm.elements['attrib-16-107'].checked == false && oForm.elements['id[txt_17]'].value == '')
{
alert("Please enter a street address for your Registrant.");
return false;
}
else{
return true;
}
}
}
</script>
Hope this helps!
Bookmarks