titan_boy Posted March 31, 2015 Posted March 31, 2015 hello all, can someone help me please with a problem? The problem is that i will make a edit box for only letters and numbers. not !~!@#$%^&* ect. i know this: theEdit = guiCreateEdit( 15, 326, 221, 33, "", false, Window["mainWindow"] ) local txt = guiGetText(theEdit) local text = string.gsub(txt, "[^a-z]", "") local text = string.gsub(txt, "[^0-9]", "") but idk what i need to do with this. help me please.
Castillo Posted March 31, 2015 Posted March 31, 2015 That would remove letters and numbers from the string. To remove all characters from a string use: local myString = "Hello World ^^,-*/-/*/-,." -- Example myString:gsub ( "%p", "" ) You can use the event onClientGUIChanged to detect when the editbox text is changed, so you can remove the characters.
titan_boy Posted March 31, 2015 Author Posted March 31, 2015 thank you Solidsnake14 but how do i put this in my script? like this?: function acceptedNames(element) local myString = "Hello World ^^,-*/-/*/-,." myString:gsub ( "%p", "" ) end addEventHandler("onClientGUIChanged", theEdit, acceptedNames, false) can someone give my an example of the function?
Castillo Posted March 31, 2015 Posted March 31, 2015 function acceptedNames ( element ) local text = guiGetText ( element ):gsub ( "%p", "" ) guiSetText ( element, text ) end addEventHandler ( "onClientGUIChanged", theEdit, acceptedNames, false )
titan_boy Posted March 31, 2015 Author Posted March 31, 2015 thank you very much Soldidsnake14!! its working!
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