Page 1 of 1

Restricting Field Input to 160 Characters

PostPosted: Sun Mar 18, 2012 1:09 pm
by dpearce
I am using a global field to input an SMS message in a text area.

Is there anyway I can restrict the input without have to click out of the field to 160 characters.

I have tried the format of the field, but that doesn't seem to work using AAAAAA 160 times.

Is there anyway to define the global variable to restrict its size to 160 characters?

Obviously one could use an on oculist or data changed, but that would only work when clicking out of the field.

David

Re: Restricting Field Input to 160 Characters

PostPosted: Sun Mar 18, 2012 2:20 pm
by ROCLASI
Hi David,

If you use SmartClient you could use the KeyListeners plugin for this. You can define a callback method on this field and make it return true or false to allow/disallow new characters to be typed (make sure you allow for delete/backspace/arrow keys/etc.).
If you use Webclient you could use the WebClientUtils plugin to inject a hook to a client-side JavaScript that handles this for you.

Hope this helps.

Re: Restricting Field Input to 160 Characters

PostPosted: Sun Mar 18, 2012 11:15 pm
by studiomiazzo
I used the format property in the designer to achieve this, i.e. I set the format of the field I want to constrai nt to something like '*****' with as many stars as needed. Not elegant but that's the only working solution I could come up with. However you could try assigning a checkLength method to your field's onDataChange event that checks for the content length, and in case reset the associated dataprovider to the allowed number of characters.

EDIT: are you sure the event is triggered only when the field losts its focus?

Re: Restricting Field Input to 160 Characters

PostPosted: Tue Mar 20, 2012 10:25 am
by jcompagner
or don't use a global field but a table field for this one, that has the 160 char length limit

Currently we don't support a max length through the designer (through the formatter or its own property) you can make a feature request for this.