Custom Option Validation in Magento

custom-optionsvalidation

I have a product with custom option using text field, I'd like a validation to it so that only letters is allow i.e. just like those "required field", alert message will pop up if your input it not accepted.

I have been looking around for hours to see where is the option-list located but with no luck.

Best Answer

Finally i found the custom-option-text field is located at: ..\app\design\frontend\base\default\template\catalog\product\view\options\type\text.phtml

for the line

<input type="text" onchange="opConfig.reloadPrice()" id=.... $_option->getIsRequire() ? 'required-entry'..... 

I used "required-entry validate-alpha" to replace the default 'required-entry', now for all custom options with text field it allows alphabet only, hard coded. Hope this may help anyone in needed.

Related Topic