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.ProxiBlue– ProxiBlue2015年01月13日 08:45:08 +00:00Commented Jan 13, 2015 at 8:45
-
Thanks i tried the extension but it is not working for me, dunno why.pakicle– pakicle2015年01月13日 17:13:10 +00:00Commented Jan 13, 2015 at 17:13
2 Answers 2
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.
-
Don't forget to mark it as resolved. Also it can be useful to read this article: inchoo.net/magento/out-of-the-box-form-validation-in-magentoDmytro– Dmytro2015年01月13日 17:14:54 +00:00Commented Jan 13, 2015 at 17:14
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:
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: