How can i restrict ‘♥♣’ like characters from saving into database. If these characters appear in name text field, a error message should be thrown.
I am using ruby on rails.
Thanks,
Anubhaw
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
See this for an example of allowing only a specific set of characters (whitelisting), which IMO is better and safer:
From:
prevent typing non ascii characters in a textbox
Alternately you can use regex to strip out non ascii characters.
see here: How to remove all non – ASCII characters from a string in Ruby