I have been working with a form in which I want the submit button to be disabled unless a textarea and a select option is chosen.
The textarea verifications works fine, the problem is with the select.
The thing is that the select takes its value from a Custom drowpdown that pases the value to the select and I think that is the problem, as the script doesn’t take it as the select has a value.
The script works if:
a) You first pick a select option and then type in the textarea.
b) You type in the textarea, select an option and then type again in the textarea.
The script for the enable/disable button is this
$(function () {
$("#result, #content-text-ta").bind("keyup change",
function () {
if ($("#content-text-ta").val() != "" && $("#result").val() != "")
$(this).closest("form").find(":submit").removeAttr("disabled").removeClass('disabled').addClass('enabled');
else
$(this).closest("form").find(":submit").attr("disabled", "disabled").removeClass('enabled').addClass('disabled');
});
});
The textarea and dropdown that pases the value to the select (id=”catselect”)
<textarea title="Post Text" name="content-text-ta" id="content-text-ta"></textarea>
<dl id="sample" class="dropdown">
<dt><a href="#" ><span class="cat" tabindex="1">Elige categoria</span></a></dt>
<dd style="z-index: 1;">
<ul>
<li><a href="#">Citas Famosas<span class="value">1</span></a></li>
<li><a href="#">Frases Bonitas<span class="value">2</span></a></li>
</ul>
</dd>
</dl>
<fieldset">
<select name='categories' id='catselect' class='tdomf_categories' size='1'>
<option id="result"></option>
</select>
</fieldset>
Use the following code:
Live Demo | Source