04-05-2017 08:14 AM
Hi,
Is there any way to prompt user when he is passing the invalid data (out of range) at the same time while my application is in run state.
For example: serial no is 0-32 bit length, and as soon as user input data which is out of range while typing it should throw pop-up or warning such as "Enter valid serial no."
Vi is attached.
04-05-2017 09:36 AM - edited 04-05-2017 09:41 AM
You should use a numeric control and make the control datatype U32. Now the range is automatically correct and values outside the range cannot be entered. Now you can eliminate all your validation code.
(For other data types or ranges, you can set the valid range using the "right-click...data entry" option.)
04-05-2017 10:02 AM
Actually valid data is string - alphanumeric.
Also, the requirement is to display pop-up or prompt users incase of invalid data entry.
Regards
Aniket
04-05-2017 10:11 AM
So you actually have a 32 CHARACTER limit. In that case, right-click on your string control and enable the "Update While Typing". Now use an Event Structure with a Value Change event on that string control. You will now get an event each time somebody types in that control. From inside of that event case, you can do whatever checks you want on the string.
04-05-2017 10:13 AM - edited 04-05-2017 10:16 AM
This sounds like a job for a regular expression A good test site is Here
But, of course, we can't help you build that regex without some knowledge about the rules of a valid serial number.
Expanding on crossrulz's idea the event driven prompt can be tweaked to discard illegal characters
04-05-2017 10:14 AM
@aniketjha wrote:
Actually valid data is string - alphanumeric.
What does that mean?
In the diagram comments it says that "Serial Number is in range from 0 to 32 bit." and I based my answer on that. You can always format the numeric input into a string if this is needed later. Is the serial number entered in decimal or e.g. hexadecimal?
04-05-2017 10:32 AM
When you say a string of alphanumeric, do you mean hexadecimal or ASCII? You can have (8) hexadecimal characters in 32-bits, but each 32-bit ASCII representation will be (4) characters with either the standard ASCII using 7-bits or using the extended ASCII which is 8-bits per character. Some of the ASCII characters are unseen, but included in the string length.
04-05-2017 10:37 AM
Hi Altenbach,
Serial number is in ASCII format.
Regards
Aniket
04-05-2017 10:40 AM
Hi Jeff,
Valid Serial Number is in ASCII format with max length of 32 bit.
Regards
Aniket
04-05-2017 10:41 AM - edited 04-05-2017 10:45 AM
@aniketjha wrote:
Serial number is in ASCII format.
ASCII is not a format. It is an ecoding sheme to assign bit patterns to displayable or control characters.
Can you show us a few valid serial numbers? Would be much more illustrative than you trying to explain it in words.