I'm having trouble with returning the appropriate responses. It sort of works like, on validation parentAnswer is ran, strips the name to reveil the parent name Answer[12]. Now if the value of this is 'yes' then I want to return that this is required if something isn't already inputted.
Was hoping there is some already in built way for the plugin to check if it's already filled out, instead of having to write messy code to do it.
<select class="input-small" name="Answers[12]">
<option value="no">No</option>
<option value="yes">Yes</option>
</select>
<textarea class="parentAnswer" rows="5" cols="107" name="Answers[12a]"></textarea>
Method
jQuery.validator.addMethod("parentAnswer", function(value, element) {
var parentElement = element.name.replace(/(.*)\[(\d*).*\]/, "$1[$2]");
var parentValue = $('select[name="'+parentElement+'"]').val();
if(parentValue === 'yes'){
return this.optional(element) || (parseFloat(value) > 0);
//^ this is the line in question
} else {
return true;
}
}, jQuery.format("Could you supply more details"));