Jump to content

How can I control whats in guiEdit?


Recommended Posts

For example I have a guiWindow all created and such but are their commands or something so the player can't enter numbers must have one space and can only contain letters and if they put in numbers or foreign symbols or if there is no text in the guiEdit the next button isn't click able and save it as the playername...I can not find anything on wiki about it Thanks

Link to comment

Omg.. next time use some periods..

So, you want only letters and the space char to be valid chars for the edit field and a next button, which only is clickable, when there is something in the edit field.

You can do this:

First of all set up a counter holding the length of your edit field input.

Then use the event onClientGUIChanged to check, if the user changed the content of the edit field.

If he added a character (string.len(guiGetText(editfield)) > editfieldLength), you just check, whether this character is a valid one.

For this you extract the character first via string.sub and then perhaps run it through a function, which checks, whether the ASCII value of this character is between a certain range (the range of the letters) + the space character value.

If yes, you don't do anything, otherwise you delete the character, again using string.sub and guiSetText.

Also, everytime the event is triggered, you check, whether the input length after the checks above here is longer than 0 and if there is a space with following letters, so that you know that the string is something like "BLA BLA".

This is just a rough solution to your problem, there is more to it and you should only work with it, if you understand everything used here completely. Otherwise this topic may still be too difficult for you and you should get more general experience with working with strings, GUI and events.

There might also be a simpler way or function to use, but this here is definitely one way.

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...