Manoj M. <
li...@ruby-forum.com> wrote:
> Hi
> anybody help me to find suitable validation way for Hash_Tag, My need is
> user should only type hash_tag like below format.
> a) #sports
> b) #sports,#news
Did you really mean "Client Side Validation" as you have in your
Subject: line? That means JavaScript, not ActiveRecord validations?
Even if you do use Client Side validation, you really need to do Server
Side as well to guard against hacks. Read about Server Side here:
http://guides.rubyonrails.org/active_record_validations.html
Follow Robert's advice as well and learn some regular expression
magic. You'll need it for either side.
I'm wondering altogether though, why the need to validate this? If the
user is typing a stream of text, they may or may not wish to include #
at some point other than as a hash tag; I think perhaps you maybe just
want to extract the hash tags that match your spec, rather than declare
the input invalid? I'm just speculating here, I obviously don't know
what your application is trying to do. It's the concept of hash tags
from twitter and now other services that I'm thinking of; a way to
denote a specific key word to search on in a stream of text.
Anyway, more code/design/info is needed to help more, I think.