Here's the code snippet:
TextField("Email", text: self.$email)
.padding()
.overlay(RoundedRectangle(cornerRadius: 1)
.stroke(Color.black, lineWidth: 1))
SecureField("Password", text: self.$password)
.padding()
.overlay(RoundedRectangle(cornerRadius: 1)
.stroke(Color.black, lineWidth: 1))
Button(action: {
print("The button was clicked!")
if loginAndPasswordAreOK() {
print("Login & Password are OK!")
} else {
self.email = ""
self.password = ""
}
}, label: {
Text("Log In")
.fontWeight(.bold)
.padding()
How can I change email's textfield's border color to red if the login & password were entered incorrectly?