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?
If you are a beginner of javascript, a better option would be
Add HTML as follows
Now add
validateForm()
asNote: This will not grey-out the submit button. But in this case submit will work only if all the entries are valid.
The script would go in the
<head></head>
of your document. Like so.One way would be to match the values of the inputs and then remove the grayed out class from your button if the values aren't still the same as the default. Here is a demo.
HTML
CSS
jQuery
http://jsfiddle.net/APGmy/11/
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.