Solved

InstallShield 2009 Premier: How to create a text box validator

Posted on 2014-10-13
4
638 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

One of the frequent problems with the installations is when some file or registry entry is not removed from the system upon un-installation of the product. Clean removal is always highly desirable. One major reason for that is badly authored inst…
Among others, I monitor the Windows Installer zone and Installer zone. I find that many of the questions could be answered much more quickly if a Windows Installer verbose log were submitted with the question.   However, I do not always have t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now