Username validation using AJAX
Posted: Fri Sep 08, 2006 8:30 am
Hi,
I am developing an application in PHP and there is one form where the user enters an username. On losing focus from the username field, we are using Ajax to check if the username exists. I am facing some problem here.
I have a span tag with an id, that holds the result from the PHP file, that checks if username exists or not. When I press tab from the username field, it displays the previous value of the span tag.
For eg, by default the span has value 0, then if username exists "1" is returned from the PHP file and using we assign that value to the span tag. On alerting, it shows 0, but whereas it should have been 1. The next time it displays 1 (because the span had the value 1 earlier). Hope I am clear.
Any help on this will be appreciated.
Thanks
I am developing an application in PHP and there is one form where the user enters an username. On losing focus from the username field, we are using Ajax to check if the username exists. I am facing some problem here.
I have a span tag with an id, that holds the result from the PHP file, that checks if username exists or not. When I press tab from the username field, it displays the previous value of the span tag.
For eg, by default the span has value 0, then if username exists "1" is returned from the PHP file and using we assign that value to the span tag. On alerting, it shows 0, but whereas it should have been 1. The next time it displays 1 (because the span had the value 1 earlier). Hope I am clear.
Any help on this will be appreciated.
Thanks