Hello. I want to have a space for users to enter their email address. I want to make it so that you have to enter an @ sign. What would the validation look like for this? Thanks
Discussion posts and replies are publicly visible
not(
like( ri!emailAddress, "*@*")
)
See how this works
Hello! This works very well. I have one other question. How may I change this code to accommodate a message? For ex: "Please Use '@'"? Thanks
If you're only interested in checking for the presence of the "@" in your validation (and validation message), then it's fairly easy to just use standard logic in the Validations: parameter of your text input field.
It would be accomplished with code similar to this:
a!textField( value: ri!email, saveInto: ri!email, validations: { if( not(like(ri!email, "*@*")), "email address must contain an '@' sign.", null() ) } )
Perfect. Thanks
No prob - but just be aware (if it matters for your use case) that this logic will also allow a user to enter a lot of things that are not a valid email address - like "mike@", or "@test", or "mike@@test.com" (and various other incorrect permutations).