Is there a way to allow the user to select values from a predefined list only using the bootstrap type Twitter? Ideally, each text value should be replaced with some numerical value (as is possible with select ).
For instance:
var regionsList = ["value1", "value2", "value3"]; var regionsCodesList = [11, 12, 77]; $('#region').typeahead({ source: regionsList });
The user should be able to enter only value1, value2 or value3 and nothing more. After submitting the form, values such as 11, 12, 77 should be passed accordingly.
Upd. I created a special verification method:
$.validator.addMethod("validRegion", function (value, element, param) { return !(param.indexOf(value) == -1); }, "Please start to input the region and then choose the value from the list");
regionsList is passed as param . But this will not work - if the user selects a value from the list with the mouse, then the error message is not hidden.
source share