[Proto-Scripty] Re: script.aculo.us autocomplete: Restrict to list
Just do an onkeypress event. Check the value of the field, and if it doesn't match what you want, delete the last character and loop until the form field value returns results from your list of acceptable words. You will want to loop in case they somehow get multiple letters entered before your script has a chance to check the field value. On Jan 12, 5:06 pm, Strider wrote: > So I was looking at something that would only let them type values > that appear in the autocomplete list. So, say it was a state list > (for example). If you type in "cal" you would have California showing > up in the list. Current autocomplete behavior allows them to type in > "Calasdfasdfasdfasdf" or whatever. I'm curious if there is a solution > already implemented that would let them type CAL and would ignore > everything else until they typed the IFORNIA in the correct order. In > other words, they're restricted to only the items on the autocomplete > list. If we have , AAAB, AAAC then after they type AAA the only > options allowed to type would be A, B, or C. > > On Jan 11, 7:34 am, shellster wrote: > > > > > Should be pretty simple: > > > var array = //your array of acceptable values; > > > $('field).observe('keyup', checkword); > > > function checkword() > > { > > var string = '/^' + RegExp.escape($('field').value) + '.*/'; > > if(array.grep(string).length == 0) > > return false; > > else > > return true; > > > } > > > Is a rough start of something. > > > On Jan 6, 2:38 pm, Strider wrote: > > > > Has anyone implemented a restrict-to-list option in the autocompleter > > > or know any of the pitfalls I should watch out for? > > > > I would like to implement this option, for say State names, or such, > > > and I would rather restrict to the list than doing post-selection > > > error messages. It seems like a feature that should be included (for > > > things like state names, or other limited lists.) > > > > Does such a feature already exist (and I missed it in my search) or > > > has anyone already implemented it? > > > > Thanks, > > > > StriderA- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: script.aculo.us autocomplete: Restrict to list
So I was looking at something that would only let them type values that appear in the autocomplete list. So, say it was a state list (for example). If you type in "cal" you would have California showing up in the list. Current autocomplete behavior allows them to type in "Calasdfasdfasdfasdf" or whatever. I'm curious if there is a solution already implemented that would let them type CAL and would ignore everything else until they typed the IFORNIA in the correct order. In other words, they're restricted to only the items on the autocomplete list. If we have , AAAB, AAAC then after they type AAA the only options allowed to type would be A, B, or C. On Jan 11, 7:34 am, shellster wrote: > Should be pretty simple: > > var array = //your array of acceptable values; > > $('field).observe('keyup', checkword); > > function checkword() > { > var string = '/^' + RegExp.escape($('field').value) + '.*/'; > if(array.grep(string).length == 0) > return false; > else > return true; > > } > > Is a rough start of something. > > On Jan 6, 2:38 pm, Strider wrote: > > > Has anyone implemented a restrict-to-list option in the autocompleter > > or know any of the pitfalls I should watch out for? > > > I would like to implement this option, for say State names, or such, > > and I would rather restrict to the list than doing post-selection > > error messages. It seems like a feature that should be included (for > > things like state names, or other limited lists.) > > > Does such a feature already exist (and I missed it in my search) or > > has anyone already implemented it? > > > Thanks, > > > StriderA -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: script.aculo.us autocomplete: Restrict to list
Should be pretty simple: var array = //your array of acceptable values; $('field).observe('keyup', checkword); function checkword() { var string = '/^' + RegExp.escape($('field').value) + '.*/'; if(array.grep(string).length == 0) return false; else return true; } Is a rough start of something. On Jan 6, 2:38 pm, Strider wrote: > Has anyone implemented a restrict-to-list option in the autocompleter > or know any of the pitfalls I should watch out for? > > I would like to implement this option, for say State names, or such, > and I would rather restrict to the list than doing post-selection > error messages. It seems like a feature that should be included (for > things like state names, or other limited lists.) > > Does such a feature already exist (and I missed it in my search) or > has anyone already implemented it? > > Thanks, > > StriderA -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: script.aculo.us autocomplete: Restrict to list
On Jan 6, 10:38 pm, Strider wrote: > Has anyone implemented a restrict-to-list option in the autocompleter > or know any of the pitfalls I should watch out for? > > I would like to implement this option, for say State names, or such, > and I would rather restrict to the list than doing post-selection > error messages. It seems like a feature that should be included (for > things like state names, or other limited lists.) > > Does such a feature already exist (and I missed it in my search) or > has anyone already implemented it? > > Thanks, > > StriderA I don't follow. Your code has to provide the options which can be offered in the Autocomplete, so can you not arrange to generate only the restricted set you want? -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.