I have the known issue with jQuery autocomplete and Remote Validation: if I write some values inside an autocomplete control, when I select the value and the control lose focus, the value passed to remote validation is the typed one and not the selected one.
For example:
I type LEO, autocomplete shows me LEO N and LEO PARD and I select LEOPARD. The remote validation is triggered, but the valued passed is the typed text LEO and NOT the selected one.
I tried the following solution described by Mr James on CulbertonExchange, but it needs to submit data to the form, while I still need to trigger the validation immediately on selection or lost focus:
<!-- THE AUTO TRIGGER TO REMOTE VALIDATION IS DISABLED, BUT THIS IS NOT REQUIRED BEHAVIOUR -->
<script type="text/javascript">
window.onload = function () {
var validatorSettings = $('#myform').validate().settings;
validatorSettings.onkeyup = false;
validatorSettings.onfocusout = false;
}
</script>
I also tried setting selectFirst
and/or autoFocus
to true
, but it still does not work:
$("#fieldtovalidate").autocomplete({
selectFirst: true,
autoFocus: false,
....
I think that I could solve my problem, disabling onkeyup and onfocusout events and re-enabling them everytime onClose
event of the autocomplete occurs? What do you think about this possible solution. How could be implemented?
Thanks in advance for your precious help!