Programmatically selecting radio button is not hiding previously displayed validation message.
Codepen: https://codepen.io/vimalanjg/pen/QQYpyE
$(function()
{
$('#myform').validate(
{
rules:
{
Color:{ required:true }
},
messages:
{
Color:
{
required:"Please select a Color<br/>"
}
},
errorPlacement: function(error, element)
{
if ( element.is(":radio") )
{
error.appendTo( element.parents('.container') );
}
else
{ // This is the default behavior
error.insertAfter( element );
}
}
});
$('#myform').submit();
$('input:radio[name="Color"][value="Red"]')
.prop('checked', true)
.trigger('change');
});
The above code is an example to reproduce the issue.
In the above snapshot, even though the radio button is selected, the validation message is still displaying.
I am wondering why jquery validation is not hiding error messages when the required value is set programmatically?
Any suggestion will be greatly appreciated.