Dinossauro Posted December 18, 2012 Share Posted December 18, 2012 Hello I have a resource login and registration here, but I do not know what is the function to block certain characters and color codes. I wonder what is the function that prevents the creation of accounts with special characters and colors. Thank you. Link to comment
uhm Posted December 18, 2012 Share Posted December 18, 2012 probably use a regular expressions like so username = 'whatever32$#@(*$59' if username:match('[a-zA-Z0-9]+') ~= nil then print 'It is alright' else print 'It contains illegal characters or is not long enough' end tested for syntax and functionality the regex I used ([a-zA-Z0-9]+) means: allow any character in range of a-z, A-Z, underscores and 0-9 and require at least one of those with no maximum check out RegExr to build and test your own regular expression Link to comment
Dinossauro Posted December 18, 2012 Author Share Posted December 18, 2012 probably use a regular expressions like so username = 'whatever32$#@(*$59' if username:match('[a-zA-Z0-9]+') ~= nil then print 'It is alright' else print 'It contains illegal characters or is not long enough' end tested for syntax and functionality the regex I used ([a-zA-Z0-9]+) means: allow any character in range of a-z, A-Z, underscores and 0-9 and require at least one of those with no maximum check out RegExr to build and test your own regular expression Could add to this script code that prohibits the use of color codes? Thank you. Link to comment
Anderl Posted December 18, 2012 Share Posted December 18, 2012 string.find String: "#%x%x%x%x%x%x" Link to comment
uhm Posted December 18, 2012 Share Posted December 18, 2012 well that code I posted doesn't allow the # character, so it already does Link to comment
Dinossauro Posted December 18, 2012 Author Share Posted December 18, 2012 But how do I apply this script to the resource? It's not working. Link to comment
uhm Posted December 18, 2012 Share Posted December 18, 2012 nay dawg you obviously need to change the hardcoded values to shiz like guiGetText and instead of those prints you do the actual handling like draw a popup when its wrong and trigger your server side code to do sql shiz Link to comment
Dinossauro Posted December 18, 2012 Author Share Posted December 18, 2012 What? O_o I do not quite understand, I'm Portuguese, my English is not so good. Link to comment
uhm Posted December 18, 2012 Share Posted December 18, 2012 Okay, I shall formulate it so it is better to understand or translatable by a machine: Indeed. The code I have posted won't work instantly. Because you must replace the values I have set manually by functions such as guiGetText. Instead of the lines where I put "print", you must put the actual handling. Such as showing a pop-up window when the check fails. And when the check succeeds, put code so your server does things like SQL "INSERT"-commands. If you are checking if the username is okay in a client-side script, you also must put a trigger for the code on the side of your server (server-side). Because you can not use SQL-commands directly on the client-side. Link to comment
Dinossauro Posted December 18, 2012 Author Share Posted December 18, 2012 You could replace these values with any example? Thanks... Link to comment
Kenix Posted December 19, 2012 Share Posted December 19, 2012 check out RegExr to build and test your own regular expression Lua used patterns, not RegExr. It's not same. Link to comment
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