I'm back with another jQuery problem, woo! Here's what I'm trying to do, I have text field, and I want it's background to turn red if the user doesn't input anything, or turn green if something is entered. Both checks occur on "blur," and I'm using ".animate()." to change the background color. (I have jQuery-Color to let me animate colors). Here is my script:
<head>
<script type="text/javascript" src="assets/javascript/jQuery.js"></script>
<script type="text/javascript" src="assets/javascript/jQuery-color.js"></script>
<script>
var jQ=jQuery.noConflict();
var fullNameValue=jQ(".fullName").attr("value");
jQ(document).ready(function(){
jQ(".fullName").blur(function(){
if(fullNameValue==null || fullNameValue==""){
jQ(".fullName").animate({
backgroundColor: "#AF383C",
color: "#FFFFFF"
});
}
else{
jQ(".fullName").animate({
backgroundColor: "#78BB6C",
color: "#000000"
});
}
});
});
</script>
</head>
Currently, on blur, the text field turns red, even if something is entered in the text field, which probably means something is wrong with my if statement, correct?
.noConflict()? It doesn't seem necessary given the code you've posted.