#45341 - 2003-09-04 12:13 AM
Form alpha numeric
|
Johan van Huyssteen_dup1
Fresh Scripter
Registered: 2003-08-28
Posts: 22
Loc: RSA
|
[Moderator (Sealeopard): Moved thread from 'Scripts' to 'Starters' forum due to lack of script in body]
I need a user interface during the login process that will ask the user office numbers. It must be 3 to 4 numbers and a selection of a,b,c,d or e example 430 c can anyone help ???? [ 17. September 2003, 19:20: Message edited by: sealeopard ]
|
|
Top
|
|
|
|
#45343 - 2003-09-04 12:25 AM
Re: Form alpha numeric
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
if you have excel in your company, you can use
$input=XLSInputBox() $room=Split($input) if $room[0]>'400' and $room[0]<'500' and $room[1]>' ' and $room[1]<'e' ...
|
|
Top
|
|
|
|
#45344 - 2003-09-03 01:38 PM
Re: Form alpha numeric
|
Johan van Huyssteen_dup1
Fresh Scripter
Registered: 2003-08-28
Posts: 22
Loc: RSA
|
I want to force the users to fill in numeric values first and then alpha values
|
|
Top
|
|
|
|
#45345 - 2003-09-03 02:05 PM
Re: Form alpha numeric
|
maciep
Korg Regular
   
Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
|
This is pretty ugly, but it seems to work.
code:
do $gotIt = 0 cls gets $x select case len($x) = 4 if val(substr($x, 1, 3)) >= 100 and val(substr($x, 1, 3)) < 1000 and instr("abcde", substr($x, 4, 1)) $gotIt = 1 endif case len($x) = 5 if val(substr($x, 1, 4)) >= 1000 and val(substr($x, 1, 4)) < 10000 and instr("abcdef", substr($x, 5, 1)) $gotIt = 1 endif case(1) ;nothing endselect until $gotIt
_________________________
Eric
|
|
Top
|
|
|
|
#45346 - 2003-09-04 10:34 AM
Re: Form alpha numeric
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Another console method...
Break ON $gNull=SetOption("Explicit","ON")
Dim $sRoomNumber,$iRoomNumberLen,$sErrorMessage,$sNumberPart
$sErrorMessage="ERROR: Room number must be 3 or 4 digits, followed by a letter a-e e.g. 405b"+@CRLF
While Not $sRoomNumber "Enter a room number (e.g. 401e): " GetS $sRoomNumber $sRoomNumber=LCase($sRoomNumber) $iRoomNumberLen=Len($sRoomNumber) Select Case $iRoomNumberLen=4 OR $iRoomNumberLen=5 If Not InStr("abcde",Right($sRoomNumber,1)) $sErrorMessage $sRoomNumber="" Else $sNumberPart=Left($sRoomNumber,$iRoomNumberLen-1) If Not $sNumberPart=Cstr(Val($sNumberPart)) $sErrorMessage $sRoomNumber="" EndIf EndIf Case "LengthIsInvalid" $sErrorMessage $sRoomNumber="" EndSelect Loop
"Valid room number entered:" $sRoomNumber ?
Exit 0
|
|
|
Top
|
|
|
|
#45348 - 2003-09-04 01:56 PM
Re: Form alpha numeric
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Then you'd have to deal with backspace, and the fact that the response may be 999x or 9999x.
What it actually needs is a good generic regular expression udf, so you can do:
code:
While Not $sRoomNumber "Enter room number: " GetS $sRoomNumber If Not Matches($sRoomNumber,"999[a-e]|9999[a-e]") "Room number is invalid." ? $sRoomNumber="" EndIf Loop
Oops. Hijacked thread
|
|
Top
|
|
|
|
#45350 - 2003-09-04 03:11 PM
Re: Form alpha numeric
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Hmm. Try: quote: "^[1-9](\d{2,3})[a-e]$$"
|
|
Top
|
|
|
|
#45351 - 2003-09-10 09:05 AM
Re: Form alpha numeric
|
Johan van Huyssteen_dup1
Fresh Scripter
Registered: 2003-08-28
Posts: 22
Loc: RSA
|
Thanks richard tested the code and its working 100%.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 895 anonymous users online.
|
|
|