BryonR Posted August 8, 2008 Share Posted August 8, 2008 I want to force a user to input a string of <Character>######### example A123456789 I understand how to force the field to have input just not the type or sting that I want. Thanks! Bryon Link to comment Share on other sites More sharing options...
JFee Posted August 8, 2008 Share Posted August 8, 2008 What I usually do when I need something like this is have it check the string each time it is changed, and if it is wrong, revert it back to what it was before. For instance: If $newString <> $oldString Then ; Do your checks to make sure it is formatted right. If $formattedWrong Then GUICtrlSetData($input, $oldString); or ControlSetText EndIf Endif Regards,Josh Link to comment Share on other sites More sharing options...
BryonR Posted August 8, 2008 Author Share Posted August 8, 2008 What I usually do when I need something like this is have it check the string each time it is changed, and if it is wrong, revert it back to what it was before. For instance: If $newString <> $oldString Then ; Do your checks to make sure it is formatted right. If $formattedWrong Then GUICtrlSetData($input, $oldString); or ControlSetText EndIf Endif how do I check to see if the format was correct? Thats the part I'm stuck at. Link to comment Share on other sites More sharing options...
bmaker Posted August 8, 2008 Share Posted August 8, 2008 You might want to use regular expressions:$input= "A123" if StringRegExp($input, "^A[0-9]+$") then ; ... else ; ... endif^A[0-9]+$ matches "A0" to "A999999999999999999999999999" (and even more digits). You might want to require a specific length:^A[0-9]{1,10}$Here, 1 is minimum and 10 is maximum number of digits.Regards, bmaker 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