Zcraks

Check signs in guiCreateEdit

Recommended Posts

How to check for signs and prohibit pressing the spacebar in guiCreateEdit ?

Share this post


Link to post
addEventHandler("onClientGUIChanged", (PASTE YOUR EDIT = VARIABLE), 
function()
    local changedStr = (PASTE YOUR EDIT = VARIABLE):getText()
    local str = changedStr:gsub(" ","")
    if str ~= changedStr then
        (PASTE YOUR EDIT = VARIABLE):setText(str)
    end
end,false)

-- enable <oop>true</oop> in meta.xml

test it

Share this post


Link to post

It is possible to make still so...

edit =  guiCreateEdit(x, y, width, heiht, "you text" ) --We set the name of a variable
str = string.gsub(guiGetText(edit), " ", "") --Get text and replace spaces
guiSetText(edit, str) --Let's replace with the ready text

P.S: string.gsub (<s>, <Search pattern>, <Replacement template>, [n])

  • S is a string.
  • Search pattern - what to search for or regular expression.
  • Replacement template - what to replace.
  • N - how many times can a replacement be made at most.

Share this post


Link to post

How add signs "A-a, ..., Z-z", "0-9",".", "_" , "@" for white list ?
And check if login_edit then do not add "@" ?

Share this post


Link to post
function replaceText()
    local text = guiGetText(source)
    local replacedText = text:gsub("[^A-Za-z0-9%._@]", "")
    if text ~= replacedText then
        guiSetText(source, replacedText)
    end
end

addEventHandler("onClientGUIChanged", login_edit, replaceText, false)

 

Share this post


Link to post

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.