I’m using jquery validation, however a few particular field values can be copied from other fields, example select menu option injections from a text field as well as math formulas populating text fields. The issue I’m having is when my js method populates a field, it still shows up as having a validation error. If I click in the field to give it focus, the validation error goes away.
Is there a way to remove the validation error after my js method has populated the field?
Code sample using trigger
$("#rowInjector_1").tapestryFormInjector("trigger").live(Tapestry.AJAXFORMLOOP_ROW_ADDED, function(){
setRequiredFields();
var injectedRow = $(this).prev().attr("id");
//adds new funding values to newly created row.
$("#" + injectedRow + " .orgKey").val(newOrgKey).trigger('change');
$("#" + injectedRow + " .category").val(newBudgetCategory).trigger('change');
$("#" + injectedRow + " .percentage").val(newPercentage).trigger('change');
$("#" + injectedRow + " .amount").val(newTotal).trigger('change');
Try triggering a change event on the input you’re copying the value into. Assigning a value to an input/select/textarea using
.val()doesn’t trigger them automatically. jQuery validation will re-fire once a change event occurs.