27 Jul
2001
27 Jul
'01
6:31 a.m.
Hi Tommy!
Another question. How do you trim a form field with dtml? I have JavaScript doing it when the form is submitted, but that doesn't help much for those browsers whose user's have disabled JavaScript.
A string is a sequence type, so you can do a simple <dtml-var "my_string[:10]"> to trim your field input (first 10 characters, in this case). Of course you can use a variable holding the length, instead of the integer literal 10... <dtml-call "REQUEST.set('my_string', 'this is way too long, man')"> <dtml-call "REQUEST.set('max_length', 6)"> <dtml-var "my_string[:max_length]"> will show up as "this i" Hope this helps, Danny