I've got a Webform working with the LiveValidation extension. I have a conditional rule that if the user selects United States, then the State-or-province field must be within the list of state abbreviations.
My problem is that if the user selects United States and then goes back and changes their answer the validation rule should be removed so they can entry any old text string. I've quadruple checked my syntax and the function is returning a liveValidation object rather than an error object but the rule is not removed. Any advice would be greatly appreciated.
Here's the script:
if($('#edit-submitted-state-or-province').length){
var field12 = new LiveValidation('edit-submitted-state-or-province', { validMessage: " ", onlyOnBlur: true });
field12.add( Validate.Presence, { failureMessage: "Please enter your state or province." } );
}
$('#edit-submitted-country').change(function() {
var stateList = new Array("","AK"..."WY");
if($("#edit-submitted-country").val() == "United States"){
field12.add( Validate.Inclusion, {within: stateList, failureMessage: "Please enter a valid 2-letter state abbreviation."});
}
else{
field12.remove( Validate.Inclusion, {within: stateList, failureMessage: "Please enter a valid 2-letter state abbreviation."});
}
});