randd Posted June 8, 2004 Share Posted June 8, 2004 I've searched through the forums and I couldn't find anything for "input validation" or "input validate". I need to validate some user supplied input and I'm not really sure how to go about doing it. It's a pretty basic input box that I'm calling to get the user to supply a date (mm/dd/yyyy). I want to verify that the user has supplied the correct format before proceeding. I know I can loop the input msgbox until the proper input is recieved, but how do I check the input and make sure it's properly formated? I the end I'll just loop the msgbox until valid input is supplied in the proper format. I figure that once I understand this I'll be able to use the concept on all user supplied input. I don't want to accept any data from a user unless I've validated it. I just don't know how to write up the validation piece. Thanks for the help! Raoul S. Duke: Few people understand the psychology of dealing with a highway traffic cop. Your normal speeder will panic and immediately pull over to the side. This is wrong. It arouses contempt in the cop-heart. Make the bastard chase you. He will follow. Link to comment Share on other sites More sharing options...
randd Posted June 8, 2004 Author Share Posted June 8, 2004 Thanks Larry. I appreciate the quick response. I'll post my results here later. Raoul S. Duke: Few people understand the psychology of dealing with a highway traffic cop. Your normal speeder will panic and immediately pull over to the side. This is wrong. It arouses contempt in the cop-heart. Make the bastard chase you. He will follow. Link to comment Share on other sites More sharing options...
randd Posted June 8, 2004 Author Share Posted June 8, 2004 My problem is I don't know how to print $statdate now that it's actually an array. I tried $startdate[1-3] but that doesn't work. I know that $startdate[0] contains the number of elements in the array. I'm not sure how to get the array back into a "normal" string again. Should I use a variable and print the array inside a for next loop? for blah blah print $startdate[$v] next? Or is it proper to assign the string to a new variable before I perform the split? Here's my code now. $bGood=0 While Not $bGood ;send popup asking for date mm/dd/yyyy $startdate = InputBox("Question", "Start Date? (format: mm/dd/yyyy)", "", "") If $startdate = "" then; if startdate blank go through and use today's date $startdateanswer = MsgBox(4, "Question", "No Value Entered. Use today's date?") If $startdateanswer = 7 Then MsgBox(4096, "Error", "Execution halted.") EXIT Else $startdate = @MON & "/" & @MDAY & "/" & @YEAR; set start date to today EndIf EndIf $startdate = StringSplit($startdate,"/") If $startdate[0] = 3 and StringLen($startdate[1])=2 And StringLen($startdate[2])=2 And _ StringLen($startdate[3]) = 4 And StringIsDigit($startdate[1]) And StringIsDigit($startdate[2]) And _ StringIsDigit($startdate[3]) Then $bGood = 1 Wend PS. What should I be using on my code to webify it so that my tabs are correctly displayed? Raoul S. Duke: Few people understand the psychology of dealing with a highway traffic cop. Your normal speeder will panic and immediately pull over to the side. This is wrong. It arouses contempt in the cop-heart. Make the bastard chase you. He will follow. Link to comment Share on other sites More sharing options...
Developers Jos Posted June 8, 2004 Developers Share Posted June 8, 2004 (edited) $WholeDate = $startdate[1] & "/" & $startdate[2] & "/" & $startdate[3] PS. What should I be using on my code to webify it so that my tabs are correctly displayed?You could run Tidy which will clean up the code for you and can convert all tabs to spaces... Edited June 8, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Nutster Posted June 8, 2004 Share Posted June 8, 2004 It is better in this situation to use DO-Until instead of While-Wend $bGood=0 Do ;send popup asking for date mm/dd/yyyy $startdate = InputBox("Question", "Start Date? (format: mm/dd/yyyy)", "", "") If $startdate = "" then; if startdate blank go through and use today's date $startdateanswer = MsgBox(4, "Question", "No Value Entered. Use today's date?") If $startdateanswer = 7 Then MsgBox(4096, "Error", "Execution halted.") EXIT Else $startdate = @MON & "/" & @MDAY & "/" & @YEAR; set start date to today $bGood = 1 EndIf Else $TESTdate = StringSplit($startdate,"/") If $TESTdate[0] = 3 and StringLen($TESTdate[1])=2 And _ StringLen($TESTdate[2])=2 And StringLen($TESTdate[3]) = 4 And _ StringIsDigit($TESTdate[1]) And StringIsDigit($TESTdate[2]) And _ StringIsDigit($TESTdate[3]) Then $bGood = 1 EndIf Until $bGood David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd... Link to comment Share on other sites More sharing options...
randd Posted June 8, 2004 Author Share Posted June 8, 2004 Thanks. I'm going to see if I can whip up some more code to verify date validity. 01-12, 01-31,1980+ I'm working on some other portion of the code now. Damn java windows create the window first and then populate with data so the winwait function doesn't have the desired result. No result is white window, results is purple. I'm going to have to see if I can match some pixels then continue with the script instead of doing the winwaitactive command. Thanks for all the help! Raoul S. Duke: Few people understand the psychology of dealing with a highway traffic cop. Your normal speeder will panic and immediately pull over to the side. This is wrong. It arouses contempt in the cop-heart. Make the bastard chase you. He will follow. Link to comment Share on other sites More sharing options...
randd Posted June 9, 2004 Author Share Posted June 9, 2004 I would just like to thank whomever was responsible for writing the pixel matching code. It has proved an life saver with java windows and it only took a few tries before I got the hang of how it works! So 'Thank you!'. Raoul S. Duke: Few people understand the psychology of dealing with a highway traffic cop. Your normal speeder will panic and immediately pull over to the side. This is wrong. It arouses contempt in the cop-heart. Make the bastard chase you. He will follow. Link to comment Share on other sites More sharing options...
tutor2000 Posted June 9, 2004 Share Posted June 9, 2004 My problem is I don't know how to print $statdate now that it's actually an array. I tried $startdate[1-3] but that doesn't work. I know that $startdate[0] contains the number of elements in the array. I'm not sure how to get the array back into a "normal" string again. Should I use a variable and print the array inside a for next loop? for blah blah print $startdate[$v] next? Or is it proper to assign the string to a new variable before I perform the split? Here's my code now. $bGood=0 While Not $bGood ;send popup asking for date mm/dd/yyyy $startdate = InputBox("Question", "Start Date? (format: mm/dd/yyyy)", "", "") If $startdate = "" then; if startdate blank go through and use today's date $startdateanswer = MsgBox(4, "Question", "No Value Entered. Use today's date?") If $startdateanswer = 7 Then MsgBox(4096, "Error", "Execution halted.") EXIT Else $startdate = @MON & "/" & @MDAY & "/" & @YEAR; set start date to today EndIf EndIf $startdate = StringSplit($startdate,"/") If $startdate[0] = 3 and StringLen($startdate[1])=2 And StringLen($startdate[2])=2 And _ StringLen($startdate[3]) = 4 And StringIsDigit($startdate[1]) And StringIsDigit($startdate[2]) And _ StringIsDigit($startdate[3]) Then $bGood = 1 Wend PS. What should I be using on my code to webify it so that my tabs are correctly displayed?I'll tell you how I've gotton around that is with different input boxes for the month day and year that way it doesn't even matter if you're a brit or a yank like me Rick Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now