Solved

InstallShield 2009 Premier: How to create a text box validator

Posted on 2014-10-13
4
676 Views
Last Modified: 2014-10-16
Product: InstallShield 2009 Premier
Package Type: Basic MSI

I need to validate a text box entry to ensure It is not empty or contain any non-alphanumeric characters.

My question is what are the steps for adding textbox validation with InstallShield 2009?

Thanks,

rick
0
Comment
Question by:sadlermd
  • 2
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
Vadim Rapp earned 500 total points
ID: 40379938
1. create custom action, for example vbscript, that will analyze the property assigned to your textbox (edit control) and set another property based on the result. For example, if the property is called MYBOX, then

value = Session.Property("MYBOX")
IsValid=True
For i = 1 To len(value)
	s = mid(value,i,1)
	Select Case s
		Case "1","2","3",(...),"A","B",(...),"Z","a","b",(...),"z"
		Case Else
		IsValid=False
	End Select
Next
if len(value)=0 then IsValid=False
If IsValid Then 
  Session.Property("TextIsValid")="1"
  Else
  Session.Property("TextIsValid")="0"
End If

Open in new window


Make the script synchronous, ignore exit code, not in any sequence.

2. Create text control near the edit control, with the text like "Invalid Input"; make it initially invisible, but specify 2 conditions, to show when TextIsValid="1" and to hide otherwise.

3. for the button "Next", create new event DoAction to run your vbscript; put it before the events that would cause the installation to proceed; for those events, specify additional condition TextIsValid="1" .
0
 

Author Comment

by:sadlermd
ID: 40382536
thanks, i will give this a try
0
 

Author Comment

by:sadlermd
ID: 40384863
This solves 99% of the problem - the issue now is how to make the "Invalid Input" message display.

Here is the sequence:

1. user enter an invalid value
2. user clicks "Next"
3. the validation occurs and prevents the user from proceeding to next page
4. the "Invalid Input" text does not appear

Here is a snippet from the log - I am validating that the name doesn't contain non-alphanumeric characters:

Action 12:17:25: MFSServerAccessInformation. Dialog created
MSI (c) (BC:30) [12:17:29:441]: PROPERTY CHANGE: Modifying MFS_NAME property. Its current value is 'NewYorkOffice'. Its new value: 'New York Office'.
MSI (c) (BC:30) [12:17:29:601]: Doing action: caVerifyAlphaNumericTextOnly
Action 12:17:29: caVerifyAlphaNumericTextOnly.
Action start 12:17:29: caVerifyAlphaNumericTextOnly.
MSI (c) (BC:A8) [12:17:29:603]: Invoking remote custom action. DLL: C:\Users\RICK~1\AppData\Local\Temp\MSIA626.tmp, Entrypoint: m1
MSI (c) (BC:04) [12:17:29:656]: PROPERTY CHANGE: Modifying ALPHA_NUMERIC_TEXT_ONLY property. Its current value is '1'. Its new value: '0'.
Action ended 12:17:29: caVerifyAlphaNumericTextOnly. Return value 1.


Note that if i click the "Back" button and then click "Next" to return to the page i'm validating, the "Invalid Input" is visible.

It seems like the Dialog Behavior "Subscriptions" page contains the answer but i'm not sure.

Thanks

rick
0
 
LVL 40

Expert Comment

by:Vadim Rapp
ID: 40385031
You are right, when property is set from within custom action, this does not cause the controls on the dialog to re-evaluate the conditions. They do it when a property is set by Installer itself, or when you re-display the dialog like you did.

To work around this problem, we can create fake property change: set another event for the Next button:

event: [dummy]
argument: dummy
condition: 1

Now Installer will see that some property might have changed, and will force the controls to re-evaluate the conditions, so the label will react.

Subscriptions that you mentioned would be logical choice, if only the event "some property was changed somewhere" was available to subscribe to; but it's not.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

One of the most frequently asked questions on EE in the "Windows Installer" zone is how to eliminate self-triggered installation of some product.  The problem occurs when, suddenly, whenever a certain application is launched, or even when a folder i…
Monitor input from a computer is usually nothing special.  In this instance it prevented anyone from using the computer.  This was a preconfiguration that didn't work.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question