X-Cart Product Options Validation

Category: X-Cart Snippets
Added:
Enter Price $
Quantity

How to validate your X-Cart product options fields?

You use the "Validation script (JavaScript)" box to enter some product option validation code...

For product option text fields / textareas...

var optiontext1 = product_option_value("OPTION CLASS"); // Product option name
if (optiontext1 == "") { // Default value
 alert("Please enter a value"); // Error Message
 $("#po123").focus(); // #po+classid
 return false;
}

For product option select dropdowns...

var optionselect1 = product_option_value("OPTION CLASS"); // Product option name
if (optionselect1 == "Select") { // Default value
 alert("Please select an option"); // Error Message
 $("#po124").focus(); // #po+classid
 return false;
}

More info here.