我不能放在一起javascript if statment to activate my submit button if(username_ready && email_ready) ("#register").removeAttr("disabled");
所以我有两个增值税,如果他们都是真的我希望提交按钮被激活。以上似乎不工作?我试图把它拴住这个......删除禁用,如果如果语句真的在JavaScript
$(document).ready(function()
{
$("#username").blur(function()
{
//remove all the class add the messagebox classes and start fading
$("#msgbox").removeClass().addClass('messagebox').text('Checking...').fadeIn(1000);
//check the username exists or not from ajax
$.post("user_availability.php",{ username:$(this).val() } ,function(data)
{
if(data=='no') //if username not avaiable
{
$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
{
//add message and change the class of the box and start fading
$(this).html('This User name Already exists').addClass('messageboxerror').fadeTo(900,1);
var username_ready = false;
});
}
else
{
$("#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);
var username_ready = true;
});
}
});
});
});
</script>
<script src="jquery.js" type="text/javascript" language="javascript"></script>
<script language="javascript">
$(document).ready(function()
{
$("#email").blur(function()
{
//remove all the class add the messagebox classes and start fading
$("#box").removeClass().addClass('messagebox').text('Checking...').fadeIn(1000);
//check the username exists or not from ajax
$.post("email_availability.php",{ email:$(this).val() } ,function(data)
{
if(data=='no') //if username not avaiable
{
$("#box").fadeTo(200,0.1,function() //start fading the messagebox
{
//add message and change the class of the box and start fading
$(this).html('This email name Already exists have you forgot your password? ').addClass('messageboxerror').fadeTo(900,1);
var email_ready = false;
});
}
else
{
$("#box").fadeTo(200,0.1,function() //start fading the messagebox
{
//add message and change the class of the box and start fading
$(this).html('Tezac Hamra').addClass('messageboxok').fadeTo(900,1);
var email_ready = true;
});
}
});
});
});
你有一个巨大的多余的代码量。 我建议你创建一个函数来显示消息,因为所有正在改变的是“email”和“username”字样 关于来自AlienWebguy的消息,请阅读[prop](http://api.jquery.com/prop /) – mplungjan