Ill do my best
extends Control
@onready var ULT = $UsernameInput/UsernameLengthTag
#@onready
@onready var UNIT = $UsernameInput/UsernameNoInputTag
@onready var usernameEntry: LineEdit = $UsernameInput #sets whatever is in the Username lineedit into a var
const i: int = 1
var username: String = ""
func _ready():
usernameEntry.text_changed.connect(_on_username_input_text_changed) # i think it connects the current lineedit text to whats being changed below
usernameEntry.grab_focus()
usernameEntry.text = ""
func _process(delta):
pass
func _on_create_button_pressed():
print("create pressed")
print(username)
func _on_username_input_text_changed(new_text):
var old_caret_position: int = usernameEntry.caret_column
var regex1: RegEx = RegEx.new() #this is the spesfici list of compiled RegEx letters
regex1.compile("[A-Za-z0-9]")
var current1:String = ""
var diff: int = regex1.search_all(new_text).size() - new_text.length()
for valid_character in regex1.search_all(new_text): #searchs the inputs that are being taken from a list in (regex1.compile)
current1 += valid_character.get_string() #adds what ever is being input after being checked into the (current1 string)
#add a way to add a signal-that is played when you input somthing not in the compile list
usernameEntry.set_text(current1) #set's what the (current1) is to the usernameEntry which is being displayed
usernameEntry.caret_column = old_caret_position + diff
print(current1)
if current1.length() >= 12:
ULT.visible = true
elif current1.length() <= 12:
ULT.visible = false
I want to have a user be able to create a Username that saves to a file on their computer. The username must not allow space's, special characters and cant be longer then 12. If the user inputs a special characters/space, goes over the word limit, or inputs nothing. I want to display a pop up that tells them they can't do that respective thing.
I also want to be able to do this with a Email input where it checks if you have a @ and a .com at the end. But also a password that wants you to input at least 1 number.
How i do this im not sure, im very new to godot and coding in general.