XWidgetSoft Forum
https://www.bbs.xwidget.com/

Restrict the amount of characters in the input (Edit)
https://www.bbs.xwidget.com/viewtopic.php?f=10&t=2045
Page 1 of 1

Author:  vlad [ August 29th, 2012, 4:30 am ]
Post subject:  Restrict the amount of characters in the input (Edit)

The following function restricts the amount of the characters in the inputBox / textField AKA [Edit] to "N" characters maximum. The characters which will be entered in the Edit after the limit - will be deleted automatically.

The function:
Code:
function limitInputTo3Chars(Sender,Key,KeyChar,Shift)
{
         var n = 3
         if (Sender.Text.length > n)
         {
            Sender.Text = Sender.Text.substring(0, n);
         }
}

Add the function name to the textBoxes' "OnKeyUp" event

Author:  qiancang [ August 29th, 2012, 6:38 pm ]
Post subject:  Re: Restrict the amount of characters in the input (Edit)

Attachment:
interception.jpg
interception.jpg [ 5.55 KiB | Viewed 6055 times ]


the interception function of the text control has the same effect.

Author:  vlad [ August 29th, 2012, 7:57 pm ]
Post subject:  Re: Restrict the amount of characters in the input (Edit)

qiancang wrote:
Attachment:
interception.jpg


the interception function of the text control has the same effect.


Took me a while to find it, thanks man! :D

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/