Jump to content

Recommended Posts

I have used jquery/ajax to check for username availability.it works fine.But how to write the code to make the username field blank ,if the username exist?

my js/ajax code is as follows

$(document).ready(function()

{

//var name=$('#username').val();

$("#username").blur(function()

{

//remove all the class add the messagebox classes and start fading

$("#msgbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");

//check the username exists or not from ajax

$.post("user_availability.php",{ user_name:$(this).val() } ,function(data)

        {

  if(data=='no') //if username not avaiable

  {

 

 

  $("#msgbox").fadeTo(200,0.1,function() //s'This User name Already exists'tart fading the messagebox

{

  //add message and change the class of the box and start fading

  $(this).html("already exist").addClass('messageboxerror').fadeTo(900,1);

  ;

});

 

          }

  else

  {

  $("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox

{

  //add message and change the class of the box and start fadingUsername available to register'

  $(this).html("Proceed").addClass('messageboxok').fadeTo(900,1);

});

  }

 

        });

 

});

});

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.