Quote OP:
"As I am pretty sure that jquery validates the fields on
onkeyup
. So If I TYPE the value in this field, it works fine but when I select the value from the autocomplete list, It does not validate the field as I can still see the error being displayed. So what can i do to make it work for both?"
The jQuery Validate plugin evaluates text input
elements by several triggers... key-up, blur, and submit button click (all fields at once).
The jQuery Validate plugin also provides you with the .valid()
method where you can trigger validation programatically.
I don't think you've shown enough relevant code, but basically, you'll need to trigger .valid()
whenever the value of the field changes.
Adjust code as required...
$('input[name="autocompletedField]').on('change', function() {
$(this).valid(); // trigger validation test
});