12-28-2013 12:30 AM
Hi there,
I need a control for the user to input some string with only alphabets and no special characters. Also need to control the number of characters to input. I search it and see someone use Xcontrol to achieve that but I really have no idea how to get that. Any other way to get this function works on string input?
12-28-2013 01:13 AM - edited 12-28-2013 01:20 AM
Set the string to "single line" and "update while typing". Use a filtering key-down event and discardunwanted characters of characters past the max length.
(Make sure not to filter edit keys, such as backspace, etc.)
(look at my very old example for ideas.)
12-28-2013 02:21 AM
@altenbach wrote:
Set the string to "single line" and "update while typing". Use a filtering key-down event and discardunwanted characters of characters past the max length.
(Make sure not to filter edit keys, such as backspace, etc.)
(look at my very old example for ideas.)
Thanks a lot. But that's works on in run time not in edit mode, right?
12-28-2013 02:29 AM
You did not specify edit mode functionality. If you need that, you need to build an x-control.
12-28-2013 03:11 AM
@altenbach wrote:
You did not specify edit mode functionality. If you need that, you need to build an x-control.
my bad. It seems that x-control is the only way to achieve that. I don't know how to program x-control, I found two examples online but it seems that we need to create the appearance ourselve. Is it possible to inherit the control for built-in string or slive string and modify the behavior to get that. I want to keep all controls the same appearance.
12-28-2013 03:18 AM
You have full control over the appearance of the x-control. I don't understand your concern.
03-05-2014 09:04 AM - edited 03-05-2014 09:08 AM
Dear Altenbach,
The VI that you have posted in (Max8Discard.vi) in Limiting Input String Length
limits the entry of string control to required length but it doesnt limit the entry of special characters.
If you have any simple way to do the same it will be very helpful
Thanks in advance...!!!
Regards,
Praveen PRVS
03-05-2014 10:14 AM
@prvs wrote:
Dear Altenbach,
The VI that you have posted in (Max8Discard.vi) in Limiting Input String Length
limits the entry of string control to required length but it doesnt limit the entry of special characters.
If you have any simple way to do the same it will be very helpful
Thanks in advance...!!!
Regards,
Praveen PRVS
Just change the check after the Lexical Class function. If you just want numbers and letters, then use the In Range & Coerce function to check for class numbers 3 through 5. Play around with the logic some more until you get what you need (I'm thinking that AND should be an OR).
03-05-2014 10:48 AM - edited 03-05-2014 10:49 AM
prvs wrote:The VI that you have posted in (Max8Discard.vi) in Limiting Input String Length
limits the entry of string control to required length but it doesnt limit the entry of special characters.
As mentioned, the main reason is to still allow editing of the string. For example if you would filter the delete key or backspace key, you would no longer be able the edit the string while entering text. For example if the max lenght is 3, you enter "abx", and immediately notice that you actually wanted to enter "abc", you would not be able to correct the entry in the usual way.
You are free to change the filtering in any way you want.
03-05-2014 10:30 PM
I understand the importance of not filtering the backspace or delete characters, but my requirement is to allow to the user to enter only the alpha-numeric characters and not to allow to enter special characters such as "!@#$%^&*()/*+...etc
But the shared code allows user to enter these special characters.
Regards,
Praveen PRVS