I am using Select2 in a Rails application. I would like to know if it is possible to restrict the input a user can pass into the tagging control using regex. So basically I want a user to only be able to type a-z, 0-9 or + and #. The rest of the characters should not be possible to enter into the control.
How do I achieve this?Thanks
Related
I am trying to search records in rails admin panel by entering a value of 569785067261691692240000 in the filter text field. I get a error "bignum too big to convert into `long'".
Search works fine if the text in the filter text field is alphanumeric but doesn't work if the text is numeric.
Can't understand what the problem is.
I am using 0.6.3 version of rails admin gem.
Your field might be defined as an integer/long field, which is limited to 2^32 or 2^64. Make it a string if you want to be able to enter such a long number.
Am not sure on how to do this but I will describe it and hopefully you all can come up with a good solution. I want to have a box (not sure if its an input of search box) that when someone types in the box it pulls values from my database and shows the closest match based on characters being typed in. If the word that is typed by the user is not there then when the form is submitted then the word is added to a database.
Additionally I want to have an add button next to the box, so that if the user wants to add more than one word they can. This means that when the add is clicked a duplicate of the first box appears which does the same thing. The values will be stored in an array.
Any idea how I can go about doing this?
I using devise to allow users to register on my website. I have field for them to put in their telephone number when registering.
I however want to split the telephone field into 3 parts so you put in different parts of the number, kind of like a date.
Is it possible in rails to do something similar like you would with a date? When you have a date select on a form it gives the field names:
model[date(1i)]
model[date(2i)]
model[date(3i)]
Is this possible with other fields?
Cheers
I do not believe it is possible to cajole the date_select/select_date family into doing what you want.
You could try to mirror the DateTimeSelector class for your purposes: https://github.com/rails/rails/blob/master/actionpack/lib/action_view/helpers/date_helper.rb
But why not just deal with this in the controller? You can slice and dice the input any way you want. If it's a one-time thing, I would do it that way. Otherwise, it might be worth your time to solve the problem in general, in which case you can make a gem for the world to use... although I think these 'i' suffixes are only useful for dates and times as far as ActiveRecord is concerned.
Referring to http://jqueryui.com/demos/autocomplete/#combobox
Is there a way to allow for searches such as:
A B C
or
ABC
to return the same results, either way.
My client has data which use alternating variations of the following for example:
A & B shoe company
and
A&B shoes co
Their users expect the jquery ui autocomplete combobox to bring up either when they type one of the following:
A & B
and
A&B
Legacy applications have allowed them this before and resultingly they have become accustomed to "expediting" their searches by sometimes excluding spaces, or other times "forgetting" to put in spaces in data such as the above.
Their current web based application makes extensive use of the jquery ui autocomplete combobox, so the intention is not to remove it and replace with some proprietary widget.
I am currently looking at modifying the actual jquery.ui.combobox.js source, but prefer to find a recommended or at least more elegant method to achieve this.
Is it possible using the Twitter API to retrieve a list of all hashtags present within a single tweet?
For example, let's say I have a tweet (let's say it has an ID of 12345) with the following text:
Hi. I love #stackoverflow because it's #superawesome. #fb
Is there an API call that will give me back #stackoverflow, #superawesome, & #fb when I give it an ID of 12345?
Or do I just have to parse the text of the tweet myself?
You'll have to use a regular expression in your language of choice
#\S+
should match any hash, beginning with # and made of a string of characters. It stops at the first space.
If you want to exclude any trailing symbol and have a letter as the last char :
#\S*\w
This expression should work in most of the regex engines I'm aware of.
You can use Tweet Entities. Just include &include_entities=1.
The Twitter API does not have any functions specifically designed for hashtags. You'll need to parse the text on your own.
Although #ialphan's solution is good, if you want to sort hashtags with occurance just use this answer in similar question:
Retrieve all hashtags from a tweet in a PHP function