I have the following form:
<form action="http://www.tahara.es/contact/subscribe.php" method="post" id="subscribe" name="subscribe">
<input type="hidden" name="action" value="subscribe">
<label>NAME:</label>
<input type="text" name="name" class="Textbox" id="sub_first_name">
<label>EMAIL:</label>
<input type="text" name="email" class="Textbox" id="sub_email">
<input type="submit" name="button" id="button" value="Subscribe" />
I would like to grey out the submit
button until both fields in the form have been filled out. I guess jquery would do the trick?
How can I do this, and where should I place the script?
Just click f12 in your browser, find the submit button in the html, and then remove the disabled ! It will submit the form even if the inputs are empty.
Submit buttons don't submit if they are not in a form.
Jquery would do that. On the .keyup event have jquery check if both field's lengths are > 0 and change the button to be disabled or not.
$('#yourButton').button("disable");
$('.fields').bind('keyup', function() {
var nameLength = $("#sub_first_name").length;
var emailLength = $("#sub_email").length;
if (nameLength > 0 && emailLength > 0)
{
$('#yourButton').button("enable");
}
} );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With