I have multiple input type="text", two input type="password" boxes with class="important" and one checkbox. When all input with class important is filed and checkbox is checked the button should be enabled,else disabled. I have this script,but when i enter text in only last input it enables button. Can someone help?
js
$(document).ready(function () {
$(".important").on('keyup blur change', function () {
$(".important").each(function () {
if ($(this).val().trim() == "") {
$('#form-right input[type="submit"]').addClass('inactive');
} else {
$('#form-right input[type="submit"]').removeClass('inactive');
}
});
});
});
this is html:
<form>
<fieldset>
<ul>
<li>
<label class="mandatory">Naziv agencije</label>
<input class="important" type="text" name="naziv_agencije" id="register_agency">
</li>
<li>
<label class="mandatory">Adresa</label>
<input class="important" type="text" name="adresa" id="register_address">
</li>
<li>
<label class="mandatory">Telefon 1</label>
<input class="important" type="text" name="telefon_1" id="register_phone">
</li>
<li>
<label>Telefon 2</label>
<input type="text" name="telefon_2" id="register_phone2">
</li>
<li>
<label>Fax</label>
<input type="text" name="fax" id="register_fax">
</li>
<li>
<label class="mandatory">E-mail</label>
<input class="important" type="text" name="email" id="register_email">
</li>
<li>
<label>Web adresa</label>
<input type="text" name="web_adresa" id="register_web">
</li>
<li>
<label class="mandatory">Korisničko ime</label>
<input class="important" type="text" name="korisnicko_ime" id="register_user">
</li>
<li>
<label class="mandatory">Lozinka</label>
<input class="important" type="password" name="lozinka" id="register_pass">
</li>
<li>
<label class="mandatory">Potvrdi lozinku</label>
<input class="important" type="password" name="pot_lozinku" id="register_passr">
</li>
<li>
<label>Logo</label>
<input type="hidden" name="max_file_size">
<input type="file" name="logo" id="register_browse">
<label class="browse-button" id="register_browse">Izaberi logo</label>
<label class="file-label" id="register_browse">Logo još nije izabran</label>
</li>
<li>
<div class="checkset">
<div class="custom-true">
<input type="checkbox" name="pravila" id="register_terms">
<label>Da,slažem se sa <a href="html and css.pdf">previlima i uslovima korišćenja</a>
</label>
</div>
</div>
</li>
<li>
<input type="submit" name="register" value="registruj se" disabled="disabled" class="inactive">
</li>
<li>
<p class="catalog">Cenovnik usluga iternet sajta <a href="/" title="Last Minute Ponude">Last Minute Ponude</a>
pogledajte <a href="/">ovde</a>
.</p>
</li>
</ul>
</fieldset>
</form>