This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
tutorials:zencartmods:comments_max_length.html [2011/08/24 16:39] daigo |
tutorials:zencartmods:comments_max_length.html [2016/01/28 18:05] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | Here's a quick way to limit the length of customer comments on your invoices using javascript. Essentially, this is just a script to limit the size of a **<textarea>** element. | ||
+ | ====== Text box length limits ====== | ||
+ | |||
+ | {{:tutorials:zencartmods:limitcomment.png?|}} | ||
+ | |||
+ | Here's a quick way to limit the length of customer comments on your invoices using javascript. Essentially, this is just a script to limit the size of a **<textarea>** element. This can be handy when you need to make sure a text field doesn't have too much text in it... | ||
in both **includes/templates/YOUR_TEMPLATE/templates/tpl_checkout_shipping_default.php** and **includes/templates/YOUR_TEMPLATE/templates/tpl_checkout_payment_default.php** | in both **includes/templates/YOUR_TEMPLATE/templates/tpl_checkout_shipping_default.php** and **includes/templates/YOUR_TEMPLATE/templates/tpl_checkout_payment_default.php** | ||
Line 15: | Line 19: | ||
<script> | <script> | ||
comments = document.getElementsByName("comments")[0]; | comments = document.getElementsByName("comments")[0]; | ||
+ | |||
+ | // Cover all your bases just to be sure | ||
comments.onkeydown = commentstuff; | comments.onkeydown = commentstuff; | ||
comments.onkeypress = commentstuff; | comments.onkeypress = commentstuff; | ||
Line 37: | Line 43: | ||
- | And your done! Of course, this is pretty easy to hack (you could just turn off javascript in your browser). If you really need to limit it legitimately you should probably do it server-side in the php. | + | And you're done! Of course, this is pretty easy to hack (you could just turn off javascript in your browser). If you really need to limit this field legitimately you should probably do it server-side in the php. |
+ | |||