...

View Full Version : Show submit button when username is avaliable



bucket
03-23-2011, 01:13 AM
One more thing, how would I do it so it enables the submit button once the message is Avaliable username.

I have this code:



<script type="text/javascript">
//function to create ajax object
function pullAjax(){
var a;
try{
a=new XMLHttpRequest()
}
catch(b)
{
try
{
a=new ActiveXObject("Msxml2.XMLHTTP")
}catch(b)
{
try
{
a=new ActiveXObject("Microsoft.XMLHTTP")
}
catch(b)
{
alert("Your browser broke!");return false
}
}
}
return a;
}

function validate()
{
site_root = '';
var x = document.getElementById('uname');
var msg = document.getElementById('msg');
var submituser = document.getElementById('submituser');
user = x.value;

code = '';
message = '';
obj=pullAjax();
obj.onreadystatechange=function()
{
if(obj.readyState==4)
{
eval("result = "+obj.responseText);
code = result['code'];
message = result['result'];

if(code <=0)
{
x.style.border = "1px solid red";
msg.style.color = "red";

}
else
{
x.style.border = "1px solid #000";
msg.style.color = "green";
usersubmit.style.display = 'block';
}
msg.innerHTML = message;
}
}
obj.open("GET",site_root+"js/user_availability.php?username="+user,true);
obj.send(null);
}
</script>


and the form is here:


echo "<form action='' method='POST'>";
echo '
User Name :
<input type="text" onblur="validate();" id="uname" name="uname" value="" />
<div id="msg"></div>';

echo "next info";

echo "<input name='step3' value='Next' id='submituser' style='display:none' type='submit' />";
echo "</form>";


I set it as display none as a default and then when the box is green for the box to show as a block.

Its not showing up tho after the box becomes green

Old Pedant
03-23-2011, 02:54 AM
Ready to kick yourself?


var submituser = document.getElementById('submituser');
...
usersubmit.style.display = 'block';



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum