cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
vasanthakumarmk
Level 5

How to validate text in install script?

Jump to solution

I want to have only string without using special characters in text box. 
How to validate it? How to use Regex in install shield code? 

Regards,

Vasanth

Labels (1)
0 Kudos
(1) Solution
Jenifer
Flexera Alumni

Hi @vasanthakumarmk ,

 

How about adding function which will get substring of given string character by character and validate based on string operator %.?

pseudo code would be:

prototype IsSpecialChar (string);

function IsSpecialChar (szStuff)

/* Check if a string has special charecter

In: szStuff -- string to test
Out: Returns TRUE or FALSE

*/

#define SPECIAL_CHARS "%$#@*)(+~"
// For my purposes, underscore is considered alphanumeric.
number nPos;
string szChar;

begin
for nPos = 0 to StrLength (szStuff)
StrSub (szChar, szStuff, nPos - 1, 1);
if !(SPECIAL_CHARS % szChar) then
return FALSE;
endif;
endfor;
return TRUE;
end;

 

Hope it helps,

Thanks,

Jenifer

View solution in original post

0 Kudos
(2) Replies
Jenifer
Flexera Alumni

Hi @vasanthakumarmk ,

 

How about adding function which will get substring of given string character by character and validate based on string operator %.?

pseudo code would be:

prototype IsSpecialChar (string);

function IsSpecialChar (szStuff)

/* Check if a string has special charecter

In: szStuff -- string to test
Out: Returns TRUE or FALSE

*/

#define SPECIAL_CHARS "%$#@*)(+~"
// For my purposes, underscore is considered alphanumeric.
number nPos;
string szChar;

begin
for nPos = 0 to StrLength (szStuff)
StrSub (szChar, szStuff, nPos - 1, 1);
if !(SPECIAL_CHARS % szChar) then
return FALSE;
endif;
endfor;
return TRUE;
end;

 

Hope it helps,

Thanks,

Jenifer

0 Kudos
Thank you so much.... You really great and helped lot.... Its working fine. Cheerssss!!!!!!
0 Kudos