This may help you:
http://beski.wordpress.com/2009/05/16/check-email-already-exist-ajax-jquery/

On Jul 20, 5:28 pm, psykeeq <ales.fa...@gmail.com> wrote:
> So I have a JQuery/ajax username availability check function which
> calls a file check.php that scans the database  for existing username
> and lets you know if the one typed in is occupied or not. And this
> availabilty check is inside a registration form witch has some simple
> validation rules like required password, required email... The only
> think that is getting me frustrated is that even if the uname function
> says that the "username is not available" the form lets me through and
> I can still press the submit button and go to the next page.
> So I want my form not to validate if this function tells that the
> username is not available.
> I tried to create a custom rule and some other things but I couldnt
> get it done so if somebody could help me it would be really great. tnx
>
> $(document).ready(function()
> {
>         $("#uname").blur(function()
>         {
>                 $("#msgbox").removeClass().addClass('messagebox').text
> ('Checking...').fadeIn(1000);//remove all the class add the messagebox
> classes and start fading
>                 $.get("check.php",{ uname:$(this).val() } 
> ,function(data)//check the
> username exists or not from ajax
>         {
>                   if(data=='no') //if username not avaiable
>                   {
>                         $("#msgbox").fadeTo(200,0.1,function() //start fading 
> the
> messagebox
>                         {
>                          $(this).html('This User name Already 
> exists').addClass
> ('messageboxerror').fadeTo(900,1); //add message and change the class
> of the box and start fading
>                         });
>           }
>                   else if(data='yes')
>                   {
>                         $("#msgbox").fadeTo(200,0.1,function()  //start 
> fading the
> messagebox
>                         {
>                           //add message and change the class of the box and 
> start fading
>                           $(this).html('Username available to 
> register').addClass
> ('messageboxok').fadeTo(900,1);
>                         });
>                   }
>         });
>         });

Reply via email to