Nathan Riley
asked on
Check Database for Username
I have an html5 form that is for new users to register. When hitting the submit button I need to check and see if that username is taken before they register. I'm assuming this is done with javascript, but I don't know that language.
Are you using jQuery?
ASKER
Not yet, but I'm open to do so.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
On submit you should check if certain records excists in your database per cell.
if excisting throw a message and if all are unique create the row or am i thinking to easely?
if excisting throw a message and if all are unique create the row or am i thinking to easely?
Unless there are a very large number of users, then 99.999% of the time there is not going to be a duplicate id. You have to validate everything on the server before it goes into the database, so the extra traffic and client side code is really a waste of resources. Just check it as part of server side validation and send back an error response like you would for any other field that is a problem. Adding a server and DB hit for something like this is really unnecessary, and adds nothing to the value of the page.
Cd&
Cd&
Disagree with you Cd&
Since 99.999% of users tend to all want the same kinds of usernames this is a perfect example of presenting a user experience where they are not waiting to see if their request is successful, also add to that, that it is a tiny hit on the server compared to repeatedly doing a submit until they enter a username that is available.
Since 99.999% of users tend to all want the same kinds of usernames this is a perfect example of presenting a user experience where they are not waiting to see if their request is successful, also add to that, that it is a tiny hit on the server compared to repeatedly doing a submit until they enter a username that is available.
Disagree with you Cd&
That's fine. I just do what works; I let folks know what works; then I go for a beer. The correct approach does not change because someone agrees or disagrees or if the wrong approach is adopted. Bloating the page with a Jquery library for a little validation falls right in line with the rest of the wasted resources.
Inefficiency and bloat are never the correct approach when there are effective alternatives, unless you sell servers, hosting, or bandwidth.
Cd&
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
I ended up getting it to work with ajax, thanks for the links guys.
Next related question is here:
https://www.experts-exchange.com/questions/28178981/Username-Database-Check.html
Next related question is here:
https://www.experts-exchange.com/questions/28178981/Username-Database-Check.html