In my form, I want to enable form only when all fields (and radio button list) has been selected.
So far, I have successfully made the submit button enable
yet another solution
required = function(fields) {
var valid = true;
fields.each(function () { // iterate all
var $this = $(this);
if (($this.is(':checkbox') && !$this.is(":checked")) || // checkbox
(($this.is(':text') || $this.is('textarea')) && !$this.val()) || // text
($this.is(':radio') && !$('input[name='+ $this.attr("name") +']:checked').length)) {
valid = false;
}
});
return valid;
}
validateRealTime = function () {
var fields = $("form :input:not(:hidden)"); // select required
fields.on('keyup change keypress blur', function () {
if (required(fields)) {
{subnewtopic.disabled = false} // action if all valid
} else {
{subnewtopic.disabled = true} // action if not valid
}
});
}
http://jsfiddle.net/jsq7m8hL/2/