Trying to enable a disabled button when a textfield is not empty
So im just trying to enable a button when 3 text fields are not empty,and disable the button again if they become empty.Right now I was only trying it with one field just to get it working first but cant get it to work and no idea why.Would appreciate any help
<head> <script type="text/javascript"> function checkEnableSubmit() { if ( completePurchaseForm.address.value != "") {document.getElementById("button").disabled = false;} } </script> <form action="RegServlet" name="completePurchaseForm" method="post"> <table> <tr> <td> Address : </td><td> <input name="address" onkeyup="checkEnableSubmit()" id="address" size=100 type="text" /> </td> </tr> <tr> <td> Card Type : </td><td> <input name="cardType" id="cardType" size=15 type="text" /> </td> </tr> <tr> <td> Card Number : </td><td> <input name="cardNumber" id="cardNumber" size=15 type="text" /> </td> </tr> </table> <input type="hidden" name="action" value="completePurchase" /> <input type="button" disabled name="submit" value="Complete your purchase" /> </form>
Answers
Add id to your button <input type="button" id="button1"> to use document.getElementById("button1")