Is there was a easy way to validate unique elements in a user entered form? I found ways to do it in php(lookup values after user enters it in table) but not sure how to do it using jinja2
For example, say a user is signing up and I require all email addresses to be unique, how can I let them know its not unique before they submit the results(like this: https://github.com/signup/free if you are already a member if you enter your email it’ll tell you it exists as soon as you go to the next line. I’ve seen many sites do this)? Right now I can catch the errors but it refreshes the page and gives them an error and I’d like to let them know their form will fail before they hit submit. In this example, I’m checking for something that does not exist but in some other examples I’ll want to check if something in the database exists.
I understand I’ll need to query my database but I’m unsure how to do it from the template itself or if there’s another way to do it.
Instead of using javascript or Jquery, you could do a message system, passing it to the renderer through a dict. For example:
Just a way of doing it without the JS