In Magento 1.9,

I would like the product price to update ONLY when customer input more than 5 characters (or multiple the change-price for every 5 character added, if not too complex).
* The "price change Value" is set via the backend custom option, as below

Price Change Value

I want to add if-else to decide the onchange event, but fail to get current user input length.
file: ..\app\design\frontend\base\default\template\catalog\product\view\options\type\text.phtml

<input type="text" onchange="opConfig.reloadPrice()" id=...>

Can anyone help? Thanks in advance!

  • have you got any success to implement the such functionality
    – mjdevloper
    Commented Jan 19, 2017 at 12:03

1 Answer 1


Have you tried the following:

<input type="text" onchange="if(this.value.length > 5) opConfig.reloadPrice()" id=...>

For every multiple of 5 above 5:

<input type="text" onchange="if(this.value.length && this.value.length % 5 == 0) opConfig.reloadPrice()" id=...>
  • Thanks!! It is working BUT..even i change the input to less than 5 character the price do to the original price.<br>
    – pakicle
    Commented Jan 27, 2015 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.