Jump to content

i need to make a username field blank after checking


bindiya

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);

});

  }

 

        });

 

});

});

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.