Minimum character length before input
See original GitHub issueHi Ben!
I’m using a live search implementation on the site I’m building and I’d like to have a minumum character length before triggering the sprig request.
A google shows me this SO answer: https://stackoverflow.com/questions/66301453/minimum-number-of-characters-before-hx-get
which says I can use hx-trigger="keyup[target.value.length > 10]"
but when I try and implement this via this code:
<input sprig s-trigger="keyup[target.value.length > 3] changed[target.value.length > 3] delay:200ms" s-replace="#search-results" class="site-header__search-input" type="search" name="keywords" aria-label="Search" placeholder="Search products" value="{{ keywordSearch }}">
I can’t get Sprig to fire at all. I’ve tried just using keyup
with no changed or delay
but no dice. Am I barking up the wrong tree here? Do you have any ideas on what might be going wrong?
Thanks!
Robin
Issue Analytics
- State:
- Created a year ago
- Comments:6
Top Results From Across the Web
HTML attribute: minlength - HTML: HyperText Markup Language
The minlength attribute defines the minimum number of characters (as UTF-16 code units) the user can enter into an <input> or <textarea> ....
Read more >HTML input minlength Attribute - W3Schools
The minlength attribute specifies the minimum number of characters required in an input field. Note: The minlength attribute can be used with input...
Read more >How to specify minimum & maximum number of characters ...
To set the minimum character limit in input field, we use <input> minlength attribute. This attribute is used to specify the minimum number ......
Read more >Is there a minlength validation attribute in HTML5?
Use the minlength(/ maxlength) attribute. It specifies the minimum number of characters. For example, <input type="text" minlength ...
Read more >How to set a mininum of characters a field can have
You could add the html minlength property to the input field. Alternatively you can add an onchange event to check the length of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is a tricky one, since it throws the Sprig parser off, which takes the
>
to mean the end of the tag. I think I’m just going to recommend that you use a htmx attribute directly, which should work just fine.Good idea, I’ll try there. Thanks again!