Have an account? Sign in
Login  Register  Facebook
Problem getting color to Display
Hello,

I am using a live username check and everything works bit I have one problem.

None of the colours in the php or jquery file work. If The username is taken the form displays the error but the colour stays black when it should display in red and bold.

also if the username is free the tick displays but the colur used in the jQuery should display message stating "available" should be in green but again it display just in black.

My jQuery code is:

$(document).ready(function()
{
$("#username").keyup(function()
{

var username = $("#username").val();
var msgbox = $("#status");


if(username.length > 3)
{
$("#status").html('<img src="images/loader.gif" align="absmiddle">&nbsp;Checking availability...');

$.ajax({
type: "POST",
url: "mod/check_ajax.php",
data: "username="+ username,
success: function(msg){

$("#status").ajaxComplete(function(event, request){

if(msg == 'OK')
{

$("#username").removeClass("userred");
$("#username").addClass("usergreen");
msgbox.html('<img src="images/yes.png" align="absmiddle"> <font color="Green"> Available </font> ');
}
else
{
$("#username").removeClass("usergreen");
$("#username").addClass("userred");
msgbox.html(msg);
}

});
}

});

}
else
{
$("#username").addClass("red");
$("#status").html('<font color="#cc0000">Enter valid User Name</font>');
}



return false;
});

});

My Query to check username is:

<?php

require_once("../includes/database.php");


if(isset($_POST['username'])) {
$username = $_POST['username'];
$username = mysql_real_escape_string($username);
$sql_check = mysql_query("SELECT id FROM clients WHERE username='$username'");

if(mysql_num_rows($sql_check)) {
echo '<font color="#cc0000"><STRONG>'.$username.'</STRONG> is already in use.</font>';
} else {
echo 'OK';
}
}

?>

I just cannot figure out why the color is not displaying.

Any help is much appreciated.

Thank
Started: April 8, 2012 Latest Activity: April 8, 2012 php ajax jQuery
Your Answer

xDo you want to answer this question? Please login or create an account to post your answer