...

View Full Version : OnClick = Disable Button, Text in Form = Enable Button



tunkKid
05-19-2009, 08:46 PM
I have a message system that I want to prevent double posting. So when a user sends a message i would like to disable the button. But its done using AJAX and will load without much time. But enough to cause double clicking. So now the button needs to be enabled once Text is put in the Form Field.

Make sense??
thanks

Philip M
05-19-2009, 08:58 PM
Is this what you are wanting?


Message <input type = "text" id = "txt1" onfocus = "en()"><br>
<input type = "button" id = "but1" value = "Send Message" disabled = true onclick = "dis()">

<script type = "text/javascript">
function en() {
document.getElementById("but1").disabled = false;
}
function dis() {
document.getElementById("txt1").value = "";
document.getElementById("but1").disabled = true;
window.setTimeout("en()",5000); // disable for 5 seconds
}

</script>
Lottery: A tax on people who are bad at math.

tunkKid
05-19-2009, 09:05 PM
This will work Super-Duper!!

Thanks Alot!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum