Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Numeric values and Decimal values valiation


4 replies to this topic

vPanchumarthi

vPanchumarthi
  • Full Members
  • 56 posts

Posted 22 October 2009 - 12:10

Hi,

Iam validating a text box input while installation. Iam using StrToNum function to convert the input from a text box to number. I am able to check whether the textbox input value is 0 or not.

I was strcuk up with decimal values validation in the text box. The StrToNum function is rounding the decimal values. I should through an error message if text box contains any decimal values.

Can anybody help me out that what condition I can give to validate decimal values (in install script).

smc0862

smc0862
  • Full Members
  • 54 posts

Posted 22 October 2009 - 15:36

You could first check for the '.' using % 'String Find' option.

if (szNumber % ".") then
MessageBox("Decimal numbers not allowed.",INFORMATION);
endif;

Then do your StrToNum call.



vPanchumarthi

vPanchumarthi
  • Full Members
  • 56 posts

Posted 23 October 2009 - 06:42

Hi smc0862,

Thanks alot for your reply. Really that fix helped me. I need one more help. I want to test will all the alphabets and special characters. For that I have used 'String Find' function to check each and every alphabet and special character. But it looks clumsy by writing like that.

Is there anyway of using REGEXE in install script in order to validate alphabets and special characters for a text box input value...

I have written like this:

if (textbxvalue % ".") ||(textbxvalue % "A") || (textbxvalue % "B") || (textbxvalue % "C") || (textbxvalue % "D") || (textbxvalue % "E") ||(textbxvalue % "F") || (textbxvalue % "G") || (textbxvalue % "H") || (textbxvalue % "I") || (textbxvalue % "J") || (textbxvalue % "K") || (textbxvalue % "L") || (textbxvalue % "M") || (textbxvalue % "N") || (textbxvalue % "O") || (textbxvalue % "P") || (textbxvalue % "Q") || (textbxvalue % "R") || (textbxvalue % "S") || (textbxvalue % "T") || (textbxvalue % "U") || (textbxvalue % "V") || (textbxvalue % "W") || (textbxvalue % "X") || (textbxvalue % "Y") || (textbxvalue % "Z") || (textbxvalue % "!") || (textbxvalue % "@") || (textbxvalue % "#") || (textbxvalue % "$") || (textbxvalue % "%") || (textbxvalue % "^") || (textbxvalue % "&") || (textbxvalue % "*") || (textbxvalue % "(") || (textbxvalue % ")") || (textbxvalue % "+") || (textbxvalue % "=")|| (textbxvalue % "{") || (textbxvalue % "}") || (textbxvalue % "[") || (textbxvalue % "]") || (textbxvalue % "|") then
if (textbxvalue % "?") || (textbxvalue % "<") || (textbxvalue % ">") ||(textbxvalue % "~") || (textbxvalue % "/") then


Can anybody help me out that instead of using the above conditions whether any REGEX validation is possible in install script ...

Thanks in advance

smc0862

smc0862
  • Full Members
  • 54 posts

Posted 23 October 2009 - 11:08

Instead of using InstallScript, here is a VBScript example you could use:

'===========================================
Session.Property("IS_WHOLE_NUMBER") = "1"
If Not IsWholeNumber(Session.Property("YOUR_NUMBER")) Then
MsgBox "The value entered is not a whole number. Please supply another value."
Session.Property("IS_WHOLE_NUMBER") = "0"
End If

Function IsWholeNumber (sNumber)
IsWholeNumber = True
For iChar = 1 to Len(sNumber)
If Asc(Mid(sNumber,iChar,1)) < 48 Or Asc(Mid(sNumber,iChar,1)) > 57 Then
IsWholeNumber = False
End If
Next
End Function
'===========================================

Steps to Implement:

1.) Create a VBScript custom action called IsWholeNumber and add the above code to it.
2.) Change the MsgBox in the above code to be your message.
3.) Change the YOUR_NUMBER to the name the your property associated with the edit box you input the number into.
4.) Modify the Dialog Behavior for the Next button on the dialog that contains the edit field. Add a 'DoAction' event with an argument of "IsWholeNumber" and a condition of 1 and move it to the top of the table. Change the condition of the NewDialog event to be IS_WHOLE_NUMBER~="1"

vPanchumarthi

vPanchumarthi
  • Full Members
  • 56 posts

Posted 23 October 2009 - 16:20

Excellent! it worked for me.

Thank you smc0862[B]