Magento文本字段最大字段长度(5个字符)

时间:2014-07-10 14:05:24

标签: javascript php html css magento

我有一个magento商店。

我在每个文章网站上都有一个文本字段(http://www.lettershop.it/de/din-l-mailing-13.html):

“Anzahl”

我怎么能这样做,字段长度最多为5个字符?

1 个答案:

答案 0 :(得分:0)

您可以将html属性maxlength="5"添加到输入标记。

这可以通过浏览器工具进行操作,但没有人可能会这样做。 但是如果你想100%确定,你还必须用PHP检查它的服务器端。 你需要一个观察者。

编辑:

将maxlength属性添加到自定义选项字段:

复制

app/design/frontend/base/default/template/catalog/product/view/options/type/text.phtml

app/design/frontend/[your_package]/[your_theme]/template/catalog/product/view/options/type/text.phtml

搜索<input type="text" onchange="opConfig.reloadPrice()" ... />

并将其更改为

<input type="text" maxlength="5" onchange="opConfig.reloadPrice()" ... />

这会将maxlength添加到输入类型文本的所有自定义选项中。如果您只想要特定的自定义输入文本字段,请在模板文件中使用if / else逻辑。