I wanted to conduct a validation in javascript for some input and return valid if it is a valid Html tag.
Is there any easy way using JQuery to do that? If not then is there any way I can do it using Regex?
Thanks:)
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.
You could just make an array of valid tags then use jQuery.inArray(tag, validTags);
Here is a regex to get you started if you want to accept any tag name with only letters. It’s not been thoroughly tested, but is designed to accept one or more case-insensitive letters. If you also want to allow numbers, add in a \d between the brackets too e.g. [A-Za-Z\d].
See this page for more regex help.