I have a form that is successfully displaying jquery UI autosuggest responses from a remote database. I would like to:
- Display a custom message based on the responses (e.g., you have 10 suggested items)
- Only allow the form to be submitted (validation) if there are no autosuggest responses.
I’m not sure the best way to do this. I’m exploring an AJAX validation as a seperate thing, but perhaps there is a way to customize the jquery UI code to display the message and validate the form.
I’m happy to provide any code, but for now it’s just a simple jquery autosuggest function.
Take a look at the
.data()function on autocomplete for custom message display. The example shown on JqueryUI documentation uses it to display custom data formats. You could append your suggestion count by doing something like:As for validation if there are no items you could enable/disable the submit button based on the response you get back or populate a hidden element with information as to what to do about submitting the form.