# custom option validation

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.

• I have not used this myself, but found this the other day. rocketweb.com/custom-option-validator - the code itself may give you some idea of where to look. Jan 13 '15 at 8:45
• Thanks i tried the extension but it is not working for me, dunno why. Jan 13 '15 at 17:13

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.

Magento does not natively support the ability to provide validation on custom options. What you can do is take a look at the following third party module, developed by RocketWeb:

Custom Option Validator

I can't specifically vouch for it as I haven't found the need to use this before. But it is free and seems to do what you're looking for - so give it a shot and give us some feedback.

A great article worth reading which will allow you to implement it yourself:

Mini Tutorial: Adding REGEX Validation to Custom Options