Ajax Search And Allow Only Digits...

8 years 11 months ago #2905 by supermega
Ajax Search And Allow Only Digits... was created by supermega
Hi All,

I've Two Request:

I'll Like To Be Able To Limit The Search Field To 5 Digit For Example (just want to search fo ZIP code) But The Results Can Be Shown Only If The User Digit All The 5 Digit, If 1 2 3 or 4 No Results
Appear On The List... It's Be Possible To Make With Some Modification? I Was Able To Limit The Input
File To 5 Chars (digits and letters) But I'm Unable To Block letter Input And Force 5 Chars Input By
The User...


The Second Request Is ....It Will Be Nice To Have Ajax Search And While Typing The Resuls Populate
The List And The Map :) ...This Is More Difficult!

Later...

Please Log in to join the conversation.

More
8 years 11 months ago #2907 by sysgenmedia
Replied by sysgenmedia on topic Ajax Search And Allow Only Digits...
Hi,

For step one you can use a regex validation on the field such as:
codereview.stackexchange.com/questions/2...dation-for-zip-codes

or a more complex validation library such as: bootstrapvalidator.com/

There are many solutions for zip code validation.

Ajax search could be cool... and a basic version fairly easy to implement actually...

in the template file, on the location search field find:
onkeydown="if (event.keyCode == 13) { searchLocations(); return false; }"

and replace it with:
onkeydown="if (this.value.length > 3) { searchLocations(); }"

Where 3 is the letter after which you want to start searching... However this will likely start to show google suggestions first if enabled.
The following user(s) said Thank You: supermega

Please Log in to join the conversation.

More