Jump to content

Disallow unexpected signs


Recommended Posts

input = input:gsub("[^%w]","") 

Where 'input' is the text the user input (collected with guiGetText). %w is the character class for alphanumeric characters. ^%w means all characters that aren't alphanumeric.

Link to comment
input = input:gsub("[^%w]","") 

Where 'input' is the text the user input (collected with guiGetText). %w is the character class for alphanumeric characters. ^%w means all characters that aren't alphanumeric.

oh my god i have the problem, i'm stupid

i need to add at the server side something like:

if ( username == input:gsub("[^%w]","")) then 
.................. 
............................................... 
  
else  
outputChatBox("Choose another username, you can't use signs like: )(*&^%$#@!" ...... 
end ? 

or

  
if (username:gsub("[^%w]","")) then 

lol i have tested this like

if ( username == username:gsud("[^%w]","")) then

and when i'm tried to register username like Paulo, i've got, Choose another username

When i have tried to use $%^&, i have registered

When i use $%^&Paulo registered too :D

Edited by Guest
Link to comment
Use %W instead of ^%w.

As for your problem:

if username:find("%W") then 
    outputChatBox("Your name contains invalid characters!"); 
else 
    -- Valid username; 
end; 

  if username:find("%w") then 
                            if (accountAdded) then 
                                   exports.gtc:sendMessage("You have successfully registered. Username: " .. username .. ", password: " .. password .. " ",0,255,0, source ) 
                                   triggerClientEvent(source,"hideRegisterWindow",getRootElement()) 
                            end 
                            else 
                                 triggerClientEvent(source,"set_warning_text",getRootElement(),"MG:RP Register","Choose a different username or password.") 
                            end 

i have added this, i thought that's it's working but when i'm type only characters like: $%^, i've got error message that you name is invalid, but when i've used Paulo$%^, i 'm registered

Link to comment
if not username:find("%W") then 
    if (accountAdded) then 
        exports.gtc:sendMessage("You have successfully registered. Username: "..username..", Password: "..password,0,255,0,source); 
        triggerClientEvent(source,"hideRegisterWindow",source); 
    end; 
else 
    triggerClientEvent(source,"set_warning_text",source,"MG:RP Register","Choose a different username or password."); 
end; 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...